PDA

View Full Version : Accessing dBase database in Visual Basic


arun_rote
05-21-02, 02:27
I have a .dbf file,i want to access that file using Visual Basic 6.0.How to do this in vb can someone give a example for this.

SCIROCCO
03-14-04, 14:06
Dim cn as ADODB.Connection
Dim rs as ADODB.Recordset

Set cn = new ADODB.Connection

cn.ConnectionString = "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
"Dbq=c:\somepath"

cn.open

set rs = new ADODB.recordset

rs.ActiveConnection = cn

'Then specify the filename in the SQL statement:
rs.Open "Select * From user.dbf", oConn, , ,adCmdText

rs.Close

cn.Close

Set rs=Nothing
Set cn = Nothing

gunshy_22
04-29-04, 05:09
[QUOTE=SCIROCCO]Dim cn as ADODB.Connection
Dim rs as ADODB.Recordset

Set cn = new ADODB.Connection

cn.ConnectionString = "Driver={Microsoft dBASE Driver (*.dbf)};" & _
"DriverID=277;" & _
"Dbq=c:\somepath"

cn.open

set rs = new ADODB.recordset

rs.ActiveConnection = cn

'Then specify the filename in the SQL statement:
rs.Open "Select * From user.dbf", oConn, , ,adCmdText

rs.Close

cn.Close

Set rs=Nothing
Set cn = Nothing

i tried this code but it gives me an error of 3001: "arguments are of the wrong type, are out of acceptable range, or are in conflict with one another"... i hope anyone could help me....tnx

markalmen
05-12-04, 03:51
check out this out, this line should appear to correct the problem man...

'Then specify the filename in the SQL statement:
rs.Open "Select * From bartran.dbf", cn, , , adCmdText