ADO Object in VB Script Only Calls SQLGetData for column 1

From: Melanie Garvin (Garvin_at_discussions.microsoft.com)
Date: 10/15/04


Date: Fri, 15 Oct 2004 16:01:04 -0700

I am currently writing a test script in Visual Basic that performs a simple
query and then displays the data via the debug.write command. No matter what
I try I can only get the script to retrieve the first column of my query. I
have reviewed the ODBC trace file and can tell that vb is connecting to the
data source and executing the query. The problem seems to be that vb is not
doing a SQLBindCol followed by SQLFetch but is doing SQLGetData instead.
This would work correctly but vb seems to only be asking for SQLGetData for
column 1 each time. I am including my script incase it is something I am
doing wrong. Has anyone ever had this problem before?

Private Sub Command1_Click()
Dim adoConnection As ADODB.Connection

Dim adoRecordset As ADODB.Recordset

Dim connectString As String

Dim avarRecords As Variant

Dim intRecord As Integer

'—Create a new connection --

Set adoConnection = New ADODB.Connection

'—Create a new recordset --

Set adoRecordset = New ADODB.Recordset

adoRecordset.CursorType = adOpenStatic
adoRecordset.CursorLocation = adUseClient

'—Build our connection string to use when we open the connection --

connectString = "DSN=sc_report_odbc;UID=falcon;PWD=x"

adoConnection.Open connectString

Set adoRecordset = adoConnection.Execute("SELECT
number,contact.name,category,subcategory FROM probsummarym1")

Debug.Print "Probsummary Records"
    
Do While Not adoRecordset.EOF
  Debug.Print vbTab & adoRecordset(0) & vbTab & adoRecordset(1) & vbTab & _
              adoRecordset(2) & vbTab & adoRecordset(3)
  adoRecordset.MoveNext
Loop

End Sub



Relevant Pages

  • Re: LDAP query information
    ... a "Dim" statement. ... execution of the script. ... ' Filter on computer object. ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ... Yes, the script uses ADO to query AD directly, which is very efficient - no ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... execution of the vbscript? ... The error message indicates the line number in the script, ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... The error message indicates the line number in the script, ... Dim strBase, strFilter, strAttributes, strQuery, adoRecordset ... Set adoConnection = CreateObject ... ' Construct LDAP syntax query. ...
    (microsoft.public.windows.server.scripting)
  • Re: LDAP query information
    ... a "Dim" statement. ... script is run. ... Microsoft MVP Scripting and ADSI ... Can you please provide me info on what to do with the below query? ...
    (microsoft.public.windows.server.scripting)