|
-
Sep 11th, 2002, 11:24 AM
#1
Thread Starter
Hyperactive Member
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
-
Sep 11th, 2002, 11:48 AM
#2
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.
-
Sep 11th, 2002, 12:47 PM
#3
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|