Results 1 to 2 of 2

Thread: OleDbDatareader

  1. #1
    Join Date
    Dec 1969

    Default OleDbDatareader

    I&#039;m trying to find a way to check whether or not, my SQL query has returned a row or not, what is the proper syntax for doing this. Here is my code: <BR><BR>Private Sub submit_Click(ByVal sender As System.Object, _ <BR> ByVal e As System.EventArgs) Handles submit.Click <BR> <BR> <BR> <BR> Dim dbRead as OleDbDataReader <BR> Dim sConnectionString As String <BR> Dim PathInfo as String = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=;Data Source=" & _ <BR> "c:InetpubwwwrootGrantProposalDatabase.mdb" <BR> Dim con as OleDbConnection = new OleDbConnection(PathInfo) <BR> Dim SQL as String = "Select PASSWORD, EMAIL from CSVBannerExtract Where EMAIL = &#039;" & login.text & "&#039;" <BR> Dim da as OleDbCommand = new OleDBCommand(SQL,Con) <BR> con.Open() <BR> dbRead = da.ExecuteReader() <BR> <BR> WHILE dbRead.Read() <BR> If dbRead("PASSWORD") = password.text Then <BR> &#039;Authenticate the user <BR> FormsAuthentication.RedirectFromLoginPage(login.Te xt, False) <BR> Else <BR> lblOutput.Visible = True <BR> End If <BR> End While <BR> <BR> dbRead.close <BR> Con.close <BR> <BR> End Sub

  2. #2
    Join Date
    Dec 1969

    Default RE: OleDbDatareader

    If you are using the a DataReader, you can do the following:<BR><BR>if(dr.Read())<BR>{<BR> // return true. record found<BR>}<BR>else<BR>{<BR> // no authentication, record was not found.<BR>}<BR>

Posting Permissions

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