Results 1 to 3 of 3

Thread: Not found record

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    335

    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

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    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.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    335
    thank u

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width