There is a table tracking which has key_no,status as its field.
There is another table master which has slno,key_no,etc as its field.
In my form i hav a textbox in which one enters slno,so using this slno i want to get key_no from master table using Select query and then use this key_no to update the status in tracking table.
I have used the code which is written below,but it is not updating the value in the table tracking.
Expand|Select|Wrap|Line Numbers
- SqlConnection cn = new SqlConnection();
- cn.ConnectionString = "Data Source= abc ;Database= def;uid=pro;pwd=ghg";
- cn.Open();
- string sql = "update rock set status='INVG' where key_no=(select key_no from master where slno=@slno)";
- SqlCommand cmd= new SqlCommand(sql, cn);
- cmd.Parameters.AddWithValue("@slno", Convert.ToInt32(textBox2.Text));
- SqlDataAdapter ds = new SqlDataAdapter(k);
- ds.Fill(dd); /*dd is a instance of DataTable*/
- MessageBox.Show("Record updated");
- cn.Close();