-
Not found record
I have the following codes to connect to a database
how can I check whether a record is found or not
if not i want to provide a messge like "No record found"
Dim dt As New DataTable()
Dim conStr As String = "Provider = Microsoft.Jet.OLEDB.4.0;" & _
"Data Source = C:\contact.mdb;" & _
"User ID=Admin;" & _
"Password="
Dim sqlStr As String
sqlStr = "Select * from contact where fName Like " & "'" & "%" & txtName.Text & "%" & "'"
Dim dtAdapter As New OleDbDataAdapter(sqlStr, conStr)
dtAdapter.Fill(dt)
dtAdapter.Dispose()
dtResult.DataSource = dt
-
change DataTable to DataSet
change the fill command
.fill(dt, "mytable")
then
If dt.Tables("mytable").Rows.Count > 0 Then
' records where returned
where it say mytable. that can be anything .It doesnt have to be thta actual database table name.
-