ADO dBase connection String.

   I'm using ADO in a .asp script and I'm trying to display a dBase workbook.

I'm using the line:
filePath = Server.MapPath("serial.dbf")
Set oConn = Server.CreateObject"ADODB.Connection")

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filePath
and I get the error:

Error Type:
Microsoft JET Database Engine (0x80004005)
Unrecognized database format 'c:\inetpub\scripts\serial.DBF'.
/scripts/SimpleQuery_VBScript.asp, line 37

I know it's because I'm using the wrong connect string, but which one should I be using?
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
In this sample, «Clients» is my dbase file:

Private mcn As ADODB.Connection
Private mrst As ADODB.Recordset

Private Sub Command1_Click()
    Text1.Text = mrst.Fields(0)
End Sub

Private Sub Command2_Click()
    Text1.Text = mrst.Fields(0)
End Sub

Private Sub Form_Load()
    Set mcn = New ADODB.Connection
    mcn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\apps\office\;Extended Properties='dBase IV;';Persist Security Info=False"
    Set mrst = New ADODB.Recordset
    mrst.Open "SELECT * FROM Clients", mcn, adOpenStatic, adLockReadOnly
    Text1.Text = mrst.Fields(0)
End Sub
cideAuthor Commented:
Actually I got that to work I just have a problem with the correct SQL string I get this error:

Error Type:
Microsoft OLE DB Provider for Indexing Service (0x80040E14)
View 'SERIAL' has not been defined in catalog 'c:\inetpub\scripts\serial.dbf'. SQLSTATE=42S02
/scripts/SimpleQuery_VBScript.asp, line 43

when using:
Set oRs = oConn.Execute("SELECT * From serial")

Thanks in Advance.
What does your connection string look like?  Have you specified an Initial Catalog?
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

cideAuthor Commented:
oConn.Open "Provider=MSIDSX.1;Data Source=" & filePath
Have you tried specifying the Initial Catalog on the connection?
Éric MoreauSenior .Net ConsultantCommented:
When connecting to dBase files, your connection string look like this: Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\apps\office\;Extended Properties="dBase IV;";Persist Security Info=False

Note that the "Data Source" parameter is giving only the path to the DBF file. The DBF file will be specified in your recordset query.
cideAuthor Commented:
How would I write the recordset query then?  You have to have an example?

my db is called serial.dbf
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.