|
-
Jun 27th, 2000, 08:37 AM
#1
Thread Starter
Junior Member
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
-
Jun 27th, 2000, 12:13 PM
#2
Guru
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
-
Jun 27th, 2000, 05:15 PM
#3
Hyperactive Member
recordset
Do you know how to declare recordsets globally?
Cheers
-
Jun 28th, 2000, 01:00 PM
#4
Guru
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|