|
-
Apr 19th, 2006, 03:46 AM
#1
Re: Error handling or missing dependency file?
frayne,
What does your connection string look like?
-
Apr 19th, 2006, 06:27 AM
#2
Thread Starter
Member
Re: Error handling or missing dependency file?
Dim sSQL As String
Dim oConn As ADODB.Connection
Dim oRst As ADODB.Recordset
Dim sResults As String
' The SQL statment to retrieve the desired record(s)
sSQL = "SELECT Sixtieths FROM Distances WHERE Name = '" & member.text & _
"' AND Racepoint = '" & racepoint.text & "'"
' Allocate memory for our connection object and use a connection string to open the database
Set oConn = New ADODB.Connection
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Persist Security Info=False;" & "Data Source =" & App.Path & "\distances.mdb"
' Allocate memory for the recordset
Set oRst = New ADODB.Recordset
With oRst
' Open the recordset using our SQL string and existing connection object
.Open sSQL, oConn
' Loop through the results (in case there's more than one) until EOF (End Of File)
Do Until .EOF
' Append the results to our results string
sResults = sResults & .Fields(0).Value & vbNewLine
' Move to the next record
.MoveNext
Loop
' Close the recordset
.Close
End With
' Free memory
Set oRst = Nothing
' Close the connection
oConn.Close
' Free memory
Set oConn = Nothing
' Display results to the user
'MsgBox "The " & .racepoint.Text & "(s) from " & member.Text & " is/are:" & vbNewLine & sResults
sixtieths.text = sResults
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
|