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
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