Hi all,

i have a table "Contracts", with fields CompanyNumber, MaturityDate and other fields.

i have a form in vb.net, with a textbox that should check if the entered company number exist in my db, if it does it should check whether the maturity date is bigger or less than current date.

Any one out there that knows how to go about it? Here is the code am trying with;

Private bindingSource1 As New BindingSource()
Private dataAdapter As New OleDbDataAdapter()
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mtc.mdb"
Dim selectCommand As String
Dim connection As New OleDbConnection(connectionString)
Dim current As Date = Date.Now

selectCommand = "select * from Contracts where CompanyNumber = '" & txtCnumber.Text & "'"

Dim MyCmd As New OleDbCommand(selectCommand, connection)

Dim count As Integer
count = CInt(MyCmd.ExecuteScalar())

If count = 0 Then
MsgBox("Employee new on contract, add all areas")

ElseIf count > 0 And current.Date > "MaturityDate" Then
MsgBox("Employee already has contract and it has matured,add contract info only!")
MsgBox("Employee already has contract and it has not matured yet")
End If

5 Years
Discussion Span
Last Post by prvnkmr194

Thanx for the prvnkmr194, The Maturitydate supposed to come from the db, and compare it to current date. My question is rather how to call MaturityDate from db and do the comparison

ElseIf count > 0 And DateDiff(DateInterval.Day, "#"+MaturityDate+"#", Now())>0 Then

Here i assume that you know how to retrieve the data from database.
MaturityDate is a variable of type string which contain date in the form MM/DD/YYYY and should be enclosed within # this symbol so that it looks like #3/13/2011#

Hope it ll help you


Retrieving the data from database is a problem, excuse me but am new at all these.. please help.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.