Hi all,
I'm having a problem filling a treeview control with data from a SQL Server DB. Here is the code.
=================
Public Sub OpenMaintenance()
Dim MaintCon As New ADODB.Connection
Dim MaintRS As New ADODB.Recordset
Set MaintCon = New ADODB.Connection
MaintCon.ConnectionString = "Provider=sqloledb;" & _
"Data Source=D63WV941;Initial Catalog=TSMaster;User Id=sa;Password=sa; "
SQL = "SELECT TOP 100 PERCENT TRANSMITTAL_NR From dbo.SV_MACORD_FT_SHIP " & _
"GROUP BY TRANSMITTAL_NR " & _
"ORDER BY TRANSMITTAL_NR"
On Error GoTo MaintErr
MaintCon.ConnectionTimeout = 0
MaintCon.Open MaintCon.ConnectionString
Set MaintRS = New ADODB.Recordset
MaintRS.Open SQL, MaintCon, adOpenDynamic, adLockOptimistic, adCmdText
Do While Not MaintRS.EOF
tv1.Nodes.Add MaintRS(0).Value
MaintRS.MoveNext
Loop
MaintRS.Close
MaintCon.Close
Set MaintRS = Nothing
Set MaintCon = Nothing
Exit Sub
MaintErr:
Debug.Print Err.Number & vbCrLf & Err.Description
End Sub
================
The error I'm receiving is this:
-2147217887
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Does anyone have any ideas?
I'm having a problem filling a treeview control with data from a SQL Server DB. Here is the code.
=================
Public Sub OpenMaintenance()
Dim MaintCon As New ADODB.Connection
Dim MaintRS As New ADODB.Recordset
Set MaintCon = New ADODB.Connection
MaintCon.ConnectionString = "Provider=sqloledb;" & _
"Data Source=D63WV941;Initial Catalog=TSMaster;User Id=sa;Password=sa; "
SQL = "SELECT TOP 100 PERCENT TRANSMITTAL_NR From dbo.SV_MACORD_FT_SHIP " & _
"GROUP BY TRANSMITTAL_NR " & _
"ORDER BY TRANSMITTAL_NR"
On Error GoTo MaintErr
MaintCon.ConnectionTimeout = 0
MaintCon.Open MaintCon.ConnectionString
Set MaintRS = New ADODB.Recordset
MaintRS.Open SQL, MaintCon, adOpenDynamic, adLockOptimistic, adCmdText
Do While Not MaintRS.EOF
tv1.Nodes.Add MaintRS(0).Value
MaintRS.MoveNext
Loop
MaintRS.Close
MaintCon.Close
Set MaintRS = Nothing
Set MaintCon = Nothing
Exit Sub
MaintErr:
Debug.Print Err.Number & vbCrLf & Err.Description
End Sub
================
The error I'm receiving is this:
-2147217887
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Does anyone have any ideas?