title: how to insert into two tables from vb.net
body: <p>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.</p>
  
  <p>here is my code which i had used:</p>
  
  <pre><code>    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('" &amp; c &amp; " ' , '" &amp; sh &amp; "' ," &amp; ph &amp; ",'" &amp; ad &amp; "' ,'" &amp; TextBox5.Text &amp; "' ) "
  
      str2 = "INSERT INTO BALANCE VALUES ('" &amp; c &amp; "', " &amp; ob &amp; ")"
  
      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()
  </code></pre>