How do I connect to Mas90's file using their ODBC that they setu开发者_JS百科p - SOTAMAS90? how do I do this in vb.net ?
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
精彩评论