bopo
Member
- Joined
- Dec 10, 2006
- Messages
- 13
- Programming Experience
- Beginner
Hi
Well basically, a user enters a date into a textbox, and another date into another, I want a lable to display how many records (or rows) of information there are, between those dates.
Below is a start, but I am quite new and this coding doesnt work really, but I have given it my best shot .
Help appreciated
Well basically, a user enters a date into a textbox, and another date into another, I want a lable to display how many records (or rows) of information there are, between those dates.
Below is a start, but I am quite new and this coding doesnt work really, but I have given it my best shot .
VB.NET:
Dim cn As OleDbConnection
Dim str As String
Dim i As Long
Dim cmd As OleDbCommand
cn = New OleDbConnection
With cn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; data source = K:\Global\IT Call Log\PerDB\PermenantDB.mdb;"
End With
'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source = K:\Global\IT Call Log\PerDB\PermenantDB.mdb;")
cn.Open()
'Dim str2 As String
'str2 = "SELECT id FROM Table1 WHERE ID between '" & txtfrom.Text & "' AND '" & txtto.Text & "'"
str = "SELECT count(SubmittedAt) FROM Table1 WHERE SubmittedAt BETWEEN '" & txtfrom.Text & "' AND '" & txtto.Text & "'"
cmd = New OleDbCommand(str, cn)
Dim dr As OleDbDataReader = cmd.ExecuteReader()
If dr.HasRows() Then
dr.Read()
i = dr.GetInt32(0)
lblqueryresults.Text = dr.GetInt32(0).ToString
Else
i = -1
lblqueryresults.Text = "Nothing Found"
End If
dr.Close()
cn.Close()
cn.Dispose()