Results 1 to 3 of 3

Thread: VB.NET and Oracle problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    1

    Unhappy VB.NET and Oracle problem

    Hello There
    I am trying to connect oracle with VB.NET. The problem I am getting is that, when I try to read the datareader, I am not able to. here is my sample code -
    Private Function authenticate(ByVal user As String, ByVal passwd As String)
    Dim flag As Boolean
    Dim myConnString As String = "SERVER=some;USER ID=user;PASSWORD=pass"
    Dim mySelectQuery As String = "SELECT * FROM <table> WHERE USERNAME='" & user & "' AND PASSWORD = '" & passwd & "'"
    Dim myConnection As New OracleConnection(myConnString)
    Dim myCommand As New OracleCommand(mySelectQuery, myConnection)
    myConnection.Open()
    Dim myReader As OracleDataReader
    myReader = myCommand.ExecuteReader()
    While myReader.Read
    MessageBox.Show("Found data")
    flag = True
    End While

    If flag Then
    Return True
    Else
    Return False
    End If
    End Function


    This function is always returning false, even though data exists. WhenI tried to debug the code, I found that I I dont go in the while loop. I even tried a select * from table as my query, and it still doesnt work.

    Any help would be greatly appreciated.
    Thanks in Advance
    Srinivas

  2. #2
    Addicted Member
    Join Date
    Mar 2001
    Location
    Devon, UK
    Posts
    181
    Start with your connection string - does your connection opening?? Put some try,catch blocks in there to see if anything is going wrong.
    If you can connect then it will be your select statement, again use try/catch blocks.
    Wind and waves resolves all problems.

  3. #3
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    I dont see anything wrong with the code, except that you forgot to close the connection and the datareader.

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