i want to insert two values into two tables of a sql database which i had created. In my vb.net code my problem is if i insert it get insterted but only in one table else sometimes it's not getting inside.
here is my code which i had used:
c = TextBox1.Text sh = TextBox2.Text ph = Val(TextBox3.Text) ad = RichTextBox1.Text ob = Val(TextBox4.Text) con = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\SHOPPROJECT\SHOPPROJECT\shop.mdf;Integrated Security=True;User Instance=True") con.Open() str1 = " INSERT INTO CUSTOMER VALUES('" & c & " ' , '" & sh & "' ," & ph & ",'" & ad & "' ,'" & TextBox5.Text & "' ) " str2 = "INSERT INTO BALANCE VALUES ('" & c & "', " & ob & ")" cmd = New SqlCommand cmd.Connection = con cmd.CommandType = CommandType.Text cmd.CommandText = str1 cmd.ExecuteNonQuery() cmd.CommandText = str2 cmd.ExecuteNonQuery() MsgBox("ITEM IS INSERTED", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, "CUSTOMER ADDED") TextBox1.Clear() TextBox2.Clear() TextBox3.Clear() TextBox4.Clear() TextBox5.Clear() RichTextBox1.Clear()