VB.NET and Oracle

shireenrao

Active member
Joined
Jun 18, 2003
Messages
31
Location
Boston
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
 
Are you getting any error messages? Either the connection is not being made, the table is not found, or no data exists in the table that satisfy the WHERE clause. The user/password in the connection string must have created the table or has been granted select privileges on the table. Add a Try, Catch, End Try block to the code and display the exception in a messagebox. Also, you need to close the data reader and the connection.

Try
open connection
.
.
.
execute reader

Catch ex as oracleexception
messagebox.show(ex.message)

end try

rest of code
 
I am having problem with using System.Data.OracleClient
classes.

For some reason, even though I have instllaed the dll and added this reference to my project, the compiler says OracleConnection class is not defined.

Have you encountered this?

Burak
 
Back
Top