Problem 1:
Not very sure but I think you are missing single quotes when you are adding txtAddress and txt_id to the query.
Your query
string query1 = "insert into tbl2(id,name,address) values (" + txt_id.Text + ",'" + txt_name.Text + "'," + txt_address.Text + ")";
Should be changed to
string query1 = "insert into tbl2(id,name,address) values ('" + txt_id.Text + "','" + txt_name.Text + "','" + txt_address.Text + "')";
Also remove cmd.Parameters.AddWithValue
lines.
Problem 2:
I think you just need to join Tbl3 and Tbl4 so the query will be something like the following.
Also I have assumed that the 3 ids in Tbl4 are ID_1, ID_2 and ID_3.
I have not tested it so there might be some syntax errors.
"SELECT T3.ID, T3.NAME, T3.ADDRESS
FROM TBL3 T3
INNER JOIN TBL4 T4
ON T3.ID = T4.ID_3
WHERE T4.ID_1 = '" + txt_CID.txt + "' AND T4.ID_2 = '" + txtSID.txt + "'";
Code to show data to gridview
DataSet objDataSet = new DataSet(); SqlConnection objConn = new SqlConnection(); string query = "";//Your query here SqlCommand objComm = new SqlCommand(query, objConn); SqlDataAdapter objDataAdapter = new SqlDataAdapter(objComm); if (objConn.State == ConnectionState.Closed) { objConn.Open(); } objDataAdapter.Fill(objDataSet, "YourTableName"); dataGridView1.DataSource = objDataSet;
Hope this helps