joseph27
New member
- Joined
- Jun 8, 2019
- Messages
- 1
- Programming Experience
- Beginner
VB.NET:
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Dim RecordCount As Integer
Using cn As New OleDbConnection("Your Connection")
Using scmd As New OleDbCommand("Select Count(*) From deptsched where [dtimein] <= @TimeIn And [dtimeout] >= @TimeOut;", cn)
scmd.Parameters.Add("@TimeIn", OleDbType.Date).Value = CDate(combo1.Text)
scmd.Parameters.Add("@TimeOut", OleDbType.Date).Value = CDate(combo2.Text)
cn.Open()
RecordCount = CInt(scmd.ExecuteScalar)
End Using
End Using
If RecordCount > 0 Then MessageBox.Show("conflict")
Exit Sub
End If
Using cn As New OleDbConnection("Your Connection String")
Using cmds As New OleDbCommand("insert into deptsched values(@Field1, @Field2);", cn)
cmds.Parameters.Add("@Field1", OleDbType.VarChar).Value = c1.text
cmds.Parameters.Add("@Field2", OleDbType.VarChar).Value = c2.text
cn.Open()
cmds.ExecuteNonQuery()
End Using
please help me to conflict time sample;
7:00-8:00 it will save but when i input 7:30-8:30 it also save but it is already conflict with the first input.
can u help me find a way?
Last edited by a moderator: