Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Provider for Database not found?

Status
Not open for further replies.

blurworld

Programmer
Sep 19, 2001
46
0
0
GB
After running the following below in vb6 i get...

"Run-time error '3706'
Provider cannot be found. It may not be properly installed."
with recPerson.Open strSQL, strConnect then highligted in the debug...

what am i doing wrong? thanx
-Martin

Public Sub Load(SSN As String)
Dim recPerson As Recordset
Dim strConnect As String
Dim strSQL As String
strConnect = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Persist Security Info=False;" & _
"Data Source=C:person.mdb"
strSQL = "SELECT * FROM Person WHERE SSN='" & SSN & "'"
Set recPerson = New RecordSet
recPerson.Open strSQL, strConnect

With recPerson
If Not .EOF And Not .BOF Then
udtPerson.SSN = .Fields("SSN")
udtPerson.Name = .Fields("Name")
udtPerson.Birthdate = .Fields("Birthdate")
Else
recPerson.Close
Err.Raise vbObjectError + 1002, "Person", "SSN not on file"
End If
End With

recPerson.Close
Set recPerson = Nothing
End Sub

 
The file location was c:person.mdb...should be c:\person.mdb? Also, since you are using ADO syntax, you should declare the recordset accordingly as well as have ADO installed on the machine. I tested the code below and all seemed to work fine. Just make sure the client machine has ADO installed.


Public Sub Load(SSN As String)
Dim recPerson As [red]New ADODB[/red].Recordset
Dim strConnect As String
Dim strSQL As String
strConnect = "Provider=Microsoft.Jet.OLEDB.3.51;" & _
"Persist Security Info=False;" & _
"Data Source=C:\person.mdb"
strSQL = "SELECT * FROM Person WHERE SSN='" & SSN & "'"
recPerson.Open strSQL, strConnect
With recPerson
If Not .EOF And Not .BOF Then
udtperson.SSN = .Fields("SSN")
udtperson.Name = .Fields("Name")
udtperson.birthdate = .Fields("Birthdate")
Else
recPerson.Close
Err.Raise vbObjectError + 1002, "Person", "SSN not on file"
End If
End With
recPerson.Close
Set recPerson = Nothing
End Sub




Mark


The law, in its majestic equality, forbids the rich, as well as the poor, to sleep under the bridges, to beg in the streets, and to steal bread.

Anatole France
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top