IDbCommand, Oracle, Select query

M

Magnus Flisberg

Best programmer,

My mission is to execute a sql statement in vb.net and retrive the data
into a file. I have managed to detect som issues with my code:

queryString = "SELECT ...."

connectionString = "server=OraOLEDB.Oracle;User
id=x;password=x;Data source=x;"

Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
Try
connection.Open()
Catch ex As Exception
If log.IsErrorEnabled Then log.Error(ex.Message)
End Try
Dim reader As SqlDataReader = command.ExecuteReader()

Try
While reader.Read()
writer.WriteLine(String.Format("{0}, {1}",
reader(0), reader(1)))
End While
Finally
reader.Close()
End Try
End Using


Error at connection.Open():

"An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)"

this link : http://support.microsoft.com/kb/914277 is about how to
solve this my accepting remove access. But I think this is another
problem? I have no problem with my connectionstring...

I am running a oracle server with a database I am trying to access.

Any idea how I can reach my oracle db and get my information?

Regards,
Magnus
 
R

Rad [Visual C# MVP]

Best programmer,

My mission is to execute a sql statement in vb.net and retrive the data
into a file. I have managed to detect som issues with my code:

queryString = "SELECT ...."

connectionString = "server=OraOLEDB.Oracle;User
id=x;password=x;Data source=x;"

Using connection As New SqlConnection(connectionString)
Dim command As New SqlCommand(queryString, connection)
Try
connection.Open()
Catch ex As Exception
If log.IsErrorEnabled Then log.Error(ex.Message)
End Try
Dim reader As SqlDataReader = command.ExecuteReader()

Try
While reader.Read()
writer.WriteLine(String.Format("{0}, {1}",
reader(0), reader(1)))
End While
Finally
reader.Close()
End Try
End Using

Error at connection.Open():

"An error has occurred while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the
fact that under the default settings SQL Server does not allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could not
open a connection to SQL Server)"

this link : http://support.microsoft.com/kb/914277 is about how to
solve this my accepting remove access. But I think this is another
problem? I have no problem with my connectionstring...

I am running a oracle server with a database I am trying to access.

Any idea how I can reach my oracle db and get my information?

Regards,
Magnus

If you're connecting to an oracle database i suggest you look at the
OracleConnection, OracleCommand and the OracleDataReader classes. Those
would be the ideal classes to use for data access from an Oracle database
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top