how to connect a table in oracle to VB.net. kindly give me the sample code.

Dani AI

Generated

Summary: asked for VB.NET sample code to read an Oracle table. suggested searching, and mentioned an OLE DB approach. The OLE DB provider historically recommended on Windows is legacy and often causes bitness and deployment issues on modern systems. A more robust option is Oracle's ADO.NET provider (ODP.NET), preferably the managed package so no Oracle client install is required.

A simple, practical workflow:

  • Add the Oracle managed provider (NuGet: Oracle.ManagedDataAccess).
  • Add Imports Oracle.ManagedDataAccess.Client in the VB.NET file.
  • Use a connection string with EZ Connect or a TNS alias.
  • Open an OracleConnection, run an OracleCommand or OracleDataAdapter, fill a DataTable, then bind to a grid or process rows.
  • Use parameterized queries and store connection strings in config.

Minimal VB.NET example (illustrative):

Imports Oracle.ManagedDataAccess.Client

Dim cs As String = "User Id=scott;Password=tiger;Data Source=//dbhost:1521/ORCL;"
Using conn As New OracleConnection(cs)
    conn.Open()
    Dim da As New OracleDataAdapter("SELECT * FROM MY_TABLE", conn)
    Dim dt As New DataTable()
    da.Fill(dt)
    ' bind dt to a UI control or iterate rows
End Using

Troubleshooting notes: legacy Microsoft OLE DB for Oracle often fails in 64-bit processes (provider not registered). If that provider is chosen, run the app as x86 or use Oracle's provider instead. For web apps, put the connection string in web.config and secure credentials. For additional background on ADO.NET concepts and providers, consult the ADO.NET overview and the Oracle.ManagedDataAccess package details.

Recommended Answers

All 2 Replies

how to connect a table in oracle to VB.net. kindly give me the sample code.

Hey dis is basic.. search in t net.. u must b gettin samples... or search t threads..

just use oledb and set provider property to msdaora.everything else is same.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.