 |
|
insert 2 ตารางไม่ได้ครับ .. มันบันทึกแค่ตาราง RESV อันเดียวครับ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Dim connection As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
Dim conn As New SqlConnection(connection)
conn.Open()
Dim comm As String = "INSERT INTO GUES(GUES_NAME,GNDR,NATN,IDEN,E_MAIL,ADDR,TELP_NO)"
comm &= "VALUES('" & TextBox1.Text & "',"
comm &= "'" & TextBox2.Text & "',"
comm &= "'" & TextBox3.Text & "',"
comm &= "'" & TextBox4.Text & "',"
comm &= "'" & TextBox5.Text & "',"
comm &= "'" & TextBox6.Text & "',"
comm &= "'" & TextBox7.Text & "')"
comm = "INSERT INTO RESV(GUES_NAME,ROOM_NAME,DATE_FROM,DATE_TO,RESV_STTS,DATE_RESV)"
comm &= "VALUES('" & TextBox1.Text & "',"
comm &= "'" & lblSeleceRoom.Text & "',"
comm &= "Convert(DateTime, '" & lblSeleceDate.Text & "', 103),"
comm &= "Convert(DateTime, '" & lblSeleceDate1.Text & "', 103),"
comm &= "'A',"
comm &= "'" & DateNow & "')"
Dim command As New SqlCommand(comm, conn)
Try
command.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
Label1.Text = "ผิดพลาด"
End Try
End Sub
End Class
มันบันทึกแค่ตาราง RESV อันเดียวครับ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2010-01-18 04:37:06 |
By :
mubin |
View :
1047 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Dim connection As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
Dim conn As New SqlConnection(connection)
conn.Open()
Dim comm As String = "INSERT INTO GUES(GUES_NAME,GNDR,NATN,IDEN,E_MAIL,ADDR,TELP_NO)"
comm &= "VALUES('" & TextBox1.Text & "',"
comm &= "'" & TextBox2.Text & "',"
comm &= "'" & TextBox3.Text & "',"
comm &= "'" & TextBox4.Text & "',"
comm &= "'" & TextBox5.Text & "',"
comm &= "'" & TextBox6.Text & "',"
comm &= "'" & TextBox7.Text & "')"
'สร้าง sqlcommand อีกอันตรงนี้ แล้วสั่ง executenonquery ด้วย
comm = "INSERT INTO RESV(GUES_NAME,ROOM_NAME,DATE_FROM,DATE_TO,RESV_STTS,DATE_RESV)"
comm &= "VALUES('" & TextBox1.Text & "',"
comm &= "'" & lblSeleceRoom.Text & "',"
comm &= "Convert(DateTime, '" & lblSeleceDate.Text & "', 103),"
comm &= "Convert(DateTime, '" & lblSeleceDate1.Text & "', 103),"
comm &= "'A',"
comm &= "'" & DateNow & "')"
Dim command As New SqlCommand(comm, conn)
Try
command.ExecuteNonQuery()
conn.Close()
Catch ex As Exception
Label1.Text = "ผิดพลาด"
End Try
End Sub
End Class
|
 |
 |
 |
 |
Date :
2010-01-18 08:45:44 |
By :
tungman |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ทำได้แล้วครับ ขอบคุณท่าน tungman มาก
|
 |
 |
 |
 |
Date :
2010-01-18 15:51:19 |
By :
mubin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|