ODBC connection dataset Dbase

K

khchrist

Hello
I tried it for 2 days and read a lot of messages, but I can't find it out what's wrong with the following code.
I want to open a dBase file via Microsoft odbc.
The connection goes on without error message, but at the line
daDBF.Fill(dsFBF,"TABLE1")
the programm crashed with the error message "Systemerror"
error in Microsoft.data.Odbc.dll.

What's wrong ?
I installed all the drivers again.

The same Code with OleDb Works !

Thanks
Karl-Heinz

private void btnDBFodbc_Click(object sender, System.EventArgs e) {

System.Data.DataSet dsDBF;

string cSQLStmtDBF = @"select * from hotel";

string connStrDBF = @"Driver={Microsoft dBase Driver (*.dbf)};Initial Catalog='D:\iscralo'";

Microsoft.Data.Odbc.OdbcConnection connDBF = new Microsoft.Data.Odbc.OdbcConnection(connStrDBF);
connDBF.Open();

Microsoft.Data.Odbc.OdbcDataAdapter daDBF = new Microsoft.Data.Odbc.OdbcDataAdapter();
daDBF.SelectCommand = new Microsoft.Data.Odbc.OdbcCommand (cSQLStmtDBF,connDBF);
dsDBF = new DataSet() ;

try {
daDBF.Fill(dsDBF,"TABLE1");
connDBF.Close();
dataGrid1.SetDataBinding(dsDBF,"TABLE1");
}
catch(System.Data.Odbc.OdbcException ex) {
MessageBox.Show(ex.Message);
}

}
 
K

khchrist

Hello
I tried also the connection string

string connStrDBF = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=D:\iscralo";

without success

Karl-Heinz
 
P

Paul Clement

¤ Hello
¤ I tried also the connection string
¤
¤ string connStrDBF = @"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=D:\iscralo";
¤
¤ without success
¤
¤ Karl-Heinz

I don't see any problem with the syntax. I would just make certain the dBase driver is installed and
the dBase filename is eight characters or less (not counting the extension).


Paul
~~~~
Microsoft MVP (Visual Basic)
 
K

khchrist

Hello Paul
I think the driver is installed. The connection to the dbase-file seems is stabilized.
But it crashes when I want to fill the dataset.

in the ODBC Data Souce Administrator is listed the MS Driver with the file ODBCJT32.dll from 19.03.2003 V4.00.6200.00

Any other idea?


Karl-Heinz
 
P

Paul Clement

¤ Hello Paul
¤ I think the driver is installed. The connection to the dbase-file seems is stabilized.
¤ But it crashes when I want to fill the dataset.
¤
¤ in the ODBC Data Souce Administrator is listed the MS Driver with the file ODBCJT32.dll from 19.03.2003 V4.00.6200.00
¤
¤ Any other idea?
¤

Not for ODBC. Microsoft typically recommends using OLEDB since it's a bit more stable than ODBC.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
G

Guest

Hi Christ,

try the same with creating a DSN through ODBC, it will solve the problem.

Vijay Pote
Vijay Pote (MCP, MCAD, MCSD-In Dot Net)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top