如何使用他们设置的ODBC - SOTAMAS90连接到MAS90的文件?我如何在vb.net中做到这一点?
发布于 2009-12-08 08:31:04
I found this as an example -我自己没有尝试过100%确定它是否有效,我也没有自称是一个vb.net程序员,但至少是一些可以尝试的东西……
Imports System.Data
Imports Microsoft.Data.Odbc
' Database Connection
Public dbConn As OdbcConnection = Nothing
Public dbCmnd As OdbcCommand
Public dbReader As OdbcDataReader
Public dbConnStr As String
Public dbError As Exception
' Connect to MAS90 using ODBC; dbError stores the
' exception if any
Sub connectToDatabase(ByVal company As String, ByVal uid As String, ByVal pwd As String)
Dim dsn As String = "SOTAMAS90"
Dim timeout As String = "360"
' Build the connection string
dbConnStr = "DSN=" + dsn + _
";Directory=M:\MAS90" + _
";Prefix=M:\MAS90\soa\" + _
";ViewDLL=M:\MAS90\Home\" + _
";SERVER=NotTheServer" + _
";Company=" + company + _
";UID=" + uid + ";PWD=" + pwd + ";"
' Connect if not already
If (dbConn Is Nothing) Then
Try
dbConn = New OdbcConnection(dbConnStr)
dbConn.ConnectionTimeout = timeout
dbConn.Open()
dbError = Nothing
Catch ex As Exception
dbError = ex
dbConn = Nothing
End Try
End If
End Subhttps://stackoverflow.com/questions/1862038
复制相似问题