By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,965 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,965 IT Pros & Developers. It's quick & easy.

IDbCommand, Oracle, Select query

P: n/a
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

Dec 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 28 Dec 2006 04:24:14 -0800, Magnus Flisberg wrote:
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
--
Bits.Bytes
http://bytes.thinkersroom.com
Dec 28 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.