【问题标题】:Connecting to SOTAMAS90 ODBC?连接到 SOTAMAS90 ODBC?
【发布时间】:2009-12-07 18:44:29
【问题描述】:

如何使用他们设置的 ODBC 连接到 Mas90 的文件 - SOTAMAS90?我如何在 vb.net 中做到这一点?

【问题讨论】:

    标签: vb.net odbc connection-string


    【解决方案1】:

    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 Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多