连接到 SOTAMAS90 ODBC?

发布于 2024-08-13 17:45:46 字数 68 浏览 1 评论 0原文

如何使用他们设置的 ODBC - SOTAMAS90 连接到 Mas90 的文件?我该如何在 vb.net 中执行此操作?

How do I connect to Mas90's file using their ODBC that they setup - SOTAMAS90? how do I do this in vb.net ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萧瑟寒风 2024-08-20 17:45:46

找到了这个作为示例 - 我自己还没有尝试过知道 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

I found this as an example - I have not tried it myself to know 100% sure if it works or not, nor do I profess myself as a vb.net programmer but it's at least something to try...

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文