最近在学习vb6连接sybase ianywhere12,没有头绪啊,开发手册只有针对mobleVB的,没有针对vb6的,没办法了,求各位指教!
------解决方案--------------------
安装 ASA12的ODBC驱动,用VB连接即可
------解决方案--------------------
VB没用过,帖一段代码给你看看:
Private Sub cmdQuery_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdQuery.Click
' Declare variables
Dim i As Integer
Dim myConn As New ADODB.Connection
Dim myCommand As New ADODB.Command
Dim myRS As New ADODB.Recordset
On Error GoTo ErrorHandler
' Establish the connection
myConn.Provider = "SAOLEDB"
myConn.ConnectionString = "Data Source=SQL Anywhere 11 Demo"
myConn.CursorLocation = ADODB.CursorLocationEnum.adUseServer
myConn.Mode = ADODB.ConnectModeEnum.adModeReadWrite
myConn.IsolationLevel = ADODB.IsolationLevelEnum.adXactCursorStability
myConn.Open()
'Execute a query
myRS = New ADODB.Recordset
myRS.CacheSize = 50
myRS.let_Source("SELECT * FROM Customers")
myRS.let_ActiveConnection(myConn)
myRS.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
myRS.LockType = ADODB.LockTypeEnum.adLockOptimistic
myRS.Open()
'Scroll through the first few results
myRS.MoveFirst()
For i = 1 To 5
MsgBox(myRS.Fields("CompanyName").Value, MsgBoxStyle.Information)
myRS.MoveNext()
Next
myRS.Close()
myConn.Close()
Exit Sub
ErrorHandler:
MsgBox(ErrorToString(Err.Number))
Exit Sub
End Sub
Private Sub cmdTestConnection_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdTestConnection.Click
' Declare variables
Dim myConn As New ADODB.Connection
Dim myCommand As New ADODB.Command
Dim cAffected As Integer
On Error GoTo HandleError
' Establish the connection
myConn.Provider = "SAOLEDB"
myConn.ConnectionString = "Data Source=SQL Anywhere 11 Demo"
myConn.Open()
MsgBox("Connection succeeded")
myConn.Close()
Exit Sub
HandleError:
MsgBox(ErrorToString(Err.Number))
Exit Sub
End Sub
Private Sub cmdUpdate_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdUpdate.Click
' Declare variables
Dim myConn As New ADODB.Connection
Dim myCommand As New ADODB.Command
Dim cAffected As Integer
On Error GoTo HandleError
' Establish the connection
myConn.Provider = "SAOLEDB"
myConn.ConnectionString = "Data Source=SQL Anywhere 11 Demo"
myConn.Open()
'Execute a command
myCommand.CommandText = "UPDATE Customers SET GivenName='Liz' WHERE ID=102"
myCommand.ActiveConnection = myConn