ต้องการ insertข้อมูล 2ตารางคราวเดียวทำอย่างไรครับ
ต้องการ insertข้อมูล 2ตารางคราวเดียวทำอย่างไรครับ
ทำจาก VB2010 ฐานข้อมูล access นะครับ Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim comadd As OleDbCommand = New OleDbCommand Dim num0 As String = 0 setcombovalue() Dim NamePic As String = Now.Date.ToString("ddMMyy") & Now.TimeOfDay.Hours.ToString("00") & Now.TimeOfDay.Minutes.ToString("00") & ".jpg" Dim Openfile As String = OpenFileDialog1.FileName If BtStatus = "Add" Then sqlconn = "INSERT into tblmember(mem_id,mem_name,mem_add,mem_sex,mem_tel,mem_email,mem_con,mem_pic) VALUES('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox6.Text & "','" & tmpFileName & "')" With comadd .CommandType = CommandType.Text .CommandText = sqlconn .Connection = Conn .ExecuteNonQuery() End With sqlconn1 = "INSERT into sharesale(mem_id,share_amount,share_price,share_date,share_emp,share_sta) VALUES(" & TextBox1.Text & ", 0,0,ลงทะเบียนใหม่,'" & TextBox7.Text & "',ลงทะเบียนใหม่)" With comadd .CommandType = CommandType.Text .CommandText = sqlconn1 .Connection = Conn .ExecuteNonQuery() End With ElseIf BtStatus = "Edit" Then If tmpFileName <> "" Then sqlconn = " UPDATE tblmember SET mem_name='" & TextBox2.Text & "',mem_add='" & TextBox3.Text & "',mem_sex='" & TextBox4.Text & "',mem_tel='" & TextBox5.Text & "',mem_email='" & TextBox6.Text & "',mem_con='" & datemem & "',share_total='" & Nothing & "',mem_pic='" & tmpFileName & "' WHERE mem_id = '" & TextBox1.Text & "'" Else sqlconn = " UPDATE tblmember SET mem_name='" & TextBox2.Text & "',mem_add='" & TextBox3.Text & "',mem_sex='" & TextBox4.Text & "',mem_tel='" & TextBox5.Text & "',mem_email='" & TextBox6.Text & "',mem_con='" & datemem & "',share_total='" & Nothing & "' WHERE mem_id = '" & TextBox1.Text & "'" End If With comadd .CommandType = CommandType.Text .CommandText = sqlconn .Connection = Conn .ExecuteNonQuery() End With End sub
|