NEW to dotconnect for oracle

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
aidanc
Posts: 3
Joined: Tue 08 Dec 2009 12:59

NEW to dotconnect for oracle

Post by aidanc » Tue 08 Dec 2009 13:09

Hi,

can I write this kind of code using dotconnect

Dim strconn As String = "Data Source=" + gdatabaseip + ";Initial Catalog=" + gdatabasename + ";integrated security=false;user id=" + guserid + ";password=" + gpassword + ";connect timeout=20 "

Dim cn As New SqlConnection(strconn)

strsql = "select * from emp"
Using cmd As New SqlCommand(strsql, cn)
cmd.ExecuteQuery

what is equalvalent of the above useing dotconnect or does it all have to be done through datatable/dataadapeter classes that they provide.


thanks.

Rgds
Aidan

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 09 Dec 2009 08:07

Once dotConnect for Oracle is installed, you can connect from your application to your database with a connection string using either the Common Programming Model (via DbProviderFactory, refer to MSDN) or the dotConnect for Oracle data provider-specific objects. Here is a sample of using the dotConnect for Oracle objects:

Code: Select all

  Dim myConnString As String = "User Id=scott;Password=tiger;Server=OraServer;"
  Dim mySelectQuery As String = "select * from emp"
  Dim myConnection As New OracleConnection(myConnString)
  Dim myCommand As New OracleCommand(mySelectQuery, myConnection)
  myConnection.Open()
  Try
    Dim myReader As OracleDataReader = myCommand.ExecuteReader()
    ' Always call Read before accessing data.
    While myReader.Read()
      Console.WriteLine(myReader.GetInt32(0).ToString() + ", " _
          + myReader.GetString(myReader.GetOrdinal("ENAME")))
    End While
    ' always call Close when done reading.
    myReader.Close()
    ' Close the connection when done with it.
  Finally
    myConnection.Close()
  End Try
For more information, please refer to our tutorials. If you have any further questions, feel free to contact us.

Post Reply