두 개의 값을 내가 만든 SQL 데이터베이스의 두 테이블에 삽입하고 싶습니다. 내 vb.net 코드에서 내 문제는 만약 내가 그것을 insterted하지만 하나의 테이블에 때로는 안으로 들어가고있어 삽입 삽입 할 수 있습니다. 당신은 실제로 하나의 명령에 할, 심지어이 같은 거래에 포장 할 수vb.net에서 두 테이블에 삽입하는 방법
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()
헤이는 str1이 아래 erroe을 보여줍니다 및이 선언 된 데이터 형식 문자열 문자열을 일치하지 않는 문자를 '&'를 입력 말한다 – MUKESH
str1이 사이에 공백이 내가하지 Putten의 공간 – MUKESH
했다 미안 및 " –