This is my code. I have 3 tables named
accounts, WaterDB, ElectricDB and GasDB.
-In the code below i insert information to the acounts table.
In my accounts, WaterDB, ElectricDB and GasDB, I have a column called username.
Is it possible for me to insert the username into the other tables 'username' column as well?
Code where i insert information to my accounts table:
protected void registerBtn_Click1(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["userDatabaseConnectionString1"].ConnectionString);
conn.Open();
string insertQuery = "insert into accounts (username,email,password,postalcode,role) values (@Uname ,@email ,@pswd ,@pstlc,@role)";
SqlCommand com = new SqlCommand(insertQuery, conn);
com.Parameters.AddWithValue("@Uname", registerUsernameTB.Text);
com.Parameters.AddWithValue("@email", registerEmailTB.Text);
com.Parameters.AddWithValue("@pswd", registerUserPswdTB.Text);
com.Parameters.AddWithValue("@pstlc", postalCodeTB.Text);
com.Parameters.AddWithValue("@role", role.Text);
com.ExecuteNonQuery();
Response.Redirect("Loginx.aspx");
Response.Write("Registration is successful");
conn.Close();
}