1
Imports System.Data
Imports System.Data.SqlClient
Public Class Form2
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cmd As SqlCommand
Dim conn As SqlConnection
Dim dr2 As SqlDataReader
Dim sql = "SELECT room number,date,ddate FROM date WHERE room number = '" & nametxt.Text & "' AND date >= '" & DateTimePicker1.Text & "'AND ddate <= '" & DateTimePicker1.Text & "'OR Room number = '" & nametxt.Text & "'AND date = '" & DateTi mePicker1.Text & "' "
conn = New SqlConnection("Data Source=zahid\sqlexpress;Initial Catalog=test;Integrated Security=True")
conn.Open()
cmd = New SqlCommand(sql, conn)
Try
dr2 = cmd.ExecuteReader
If dr2.Read = True Then
MessageBox.Show("room not available...")
Else
MessageBox.Show("Login Successful...")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
If conn.State <> ConnectionState.Closed Then
conn.Close()
End If
End Sub
End Class