Results 1 to 4 of 4

Thread: The Ancient School of DB Arts

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    19

    Unhappy

    I've finally figured out how to establish a connection to my SQL server using ADO 2.1 and ODBC 3.6. Heck I can even create a DSN at run time and qry on the fly however I still can't SEE the data I'm querying for. Is there a snippet out there that demonstrates how I can view the output file via text box, debug or better yet a DataGrid or FlexGrid?

    ()()() SAMPLE CODE BELOW ()()()
    Dim dyn As Recordset
    Dim db As Database

    Private Sub cmdConnectCode_Click()

    'Set up the ODBC connection to my database
    Set db = OpenDatabase("Example", dbDriverNoPrompt, False, "ODBC;DSN=Experimental;UID=sa;PWD=;Database=MyFirstDatabase;SRVR=SQLDEVSRV001;")
    'Define and run my SQL Statement
    Set dyn = db.OpenRecordset("Select * from mypeople")
    'the mysterious output'
    End Sub


    Private Sub Form_Load()
    'CreateSQLServerDSN "MyDSN", "MyServer", "MyDatabase"
    'CreateSQLServerDSN "Experimental", "SQLDEVSRV001", "MyFirstDatabase"
    'calling param too long to paste here'
    End Sub

    -DB Grasshopper


  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    this will display all fields & records in a recordset

    Code:
    Dim I As Long
    Dim strTemp As String
    'rs = recordset    
    
    
        For I = 0 To rs.Fields.Count - 1
            strTemp = strTemp & rs.Fields(I).Name & vbTab
        Next I
        
        Debug.Print vbTab & vbTab & strTemp
        strTemp = ""
        
        Do Until rs.EOF = True
            For I = 0 To rs.Fields.Count - 1
                strTemp = strTemp & rs.Fields(I).Value & vbTab & vbTab
            Next I
            
            strTemp = strTemp & vbCrLf
            rs.MoveNext
        Loop
        
        Debug.Print strTemp

  3. #3
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Manchester
    Posts
    446

    Angry recordset

    Do you know how to declare recordsets globally?

    Cheers

  4. #4
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    put your RS declaration in a module

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width