Kbase P160513: SQL: Sample VB.NET code to establish a DSN-Less ( DSNless ) ODBC connection to an OpenEdge database.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  8/23/2010 |
|
Status: Verified
GOAL:
SQL: Sample VB.NET code to establish a DSN-Less ( DSNless ) ODBC connection to an OpenEdge database.
GOAL:
How to connect a VB .NET client to an OpenEdge database without defining a DSN?
GOAL:
What is the format of the DSN-Less connection string to an OpenEdge database?
FACT(s) (Environment):
Windows
OpenEdge 10.x
OpenEdge Category: Database
FIX:
The following VB .NET code sample demonstrates how to establish a DSN less ( DSN-Less ) connection to an OpenEdge 10.1C database. The code demonstrates the correct format of the connection string to an OpenEdge 10.1C:
Imports System
Imports System.Data
Imports System.Data.Odbc
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConnectionString As String = ("DRIVER={Progress OpenEdge 10.1C Driver};HOST=172.30.56.158;PORT=23456;DB=sports2000;UID=Administrator;PWD=Progress2010;DIL=READ UNCOMMITTED;")
Dim MySelectQuery As String = "SELECT Custnum, Name, City FROM PUB.Customer WHERE CustNum < 3"
Dim myConnection As New OdbcConnection(myConnectionString)
Dim MyCommand As New OdbcCommand(MySelectQuery, myConnection)
myConnection.Open()
MsgBox(myConnection.State.ToString)
MsgBox(myConnection.ConnectionString)
Dim myReader As OdbcDataReader = MyCommand.ExecuteReader()
Try
While myReader.Read()
MsgBox(myReader.GetString(0) + " " + myReader.GetString(1) + " " + myReader.GetString(2))
End While
Finally
myReader.Close()
myConnection.Close()
End Try
End Sub
End Class