PDA

Click to See Complete Forum and Search --> : The Ancient School of DB Arts


santiagope2000
Jun 27th, 2000, 08:37 AM
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

Clunietp
Jun 27th, 2000, 12:13 PM
this will display all fields & records in a recordset


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

gsc1ugs
Jun 27th, 2000, 05:15 PM
Do you know how to declare recordsets globally?

Cheers

Clunietp
Jun 28th, 2000, 01:00 PM
put your RS declaration in a module