This is the scenario is that am using sql server and c#.net trying to read from table using SELECT to read an value (contractId) as below code;
Code:
SqlDataReader reader8;
SqlCommand comm8;
SqlConnection conn8;
string connectionString8 = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
conn8 = new SqlConnection(connectionString8);
string sqlcomm8 = "SELECT contractId FROM contract WHERE (Seid ='" + susid + "')";
comm8 = new SqlCommand(sqlcomm8, conn8);
// Open the connection
conn8.Open();
reader8 = comm8.ExecuteReader();
reader8.Read();
p7 = Convert.ToInt32(reader8["contractId"]);
reader8.Close();
conn8.Close();
that i can get it to another sql code using UPDATE ;
Code:
SqlCommand comm9;
SqlConnection conn9;
string connectionString9 = ConfigurationManager.ConnectionStrings["DBConnectionString1"].ConnectionString;
conn9 = new SqlConnection(connectionString9);
string sqlcomm9 = "UPDATE Booking SET contractId =" + p7 + " WHERE (Seid ='" + susid + "')";
comm9 = new SqlCommand(sqlcomm9, conn9);
// Open the connection
conn9.Open();
// Execute the command
comm9.ExecuteNonQuery();
conn9.Close();
So, am using tow sql statment SELECT and UPDATE to get the value from a table to another.
My question is. Is there an sql query that i can UPDATE from SELECT WHERE Seid='" + susid + "'.
please if there a way to do that please state or tell me an a good way to do it in c#.net programming.
thanks alot in advance ...