EDN Admin
Well-known member
I have a old database type need to connect via .NET, I tried OleDb:
private void button1_Click(object sender, EventArgs e)<br/>
{<br/>
OleDbConnection connection;<br/>
OleDbCommand cmd;<br/>
OleDbDataAdapter da;<br/>
<br/>
connection = null;<br/>
cmd = null;<br/>
DataSet ds = new DataSet();<br/>
da = new OleDbDataAdapter();<br/>
<br/>
String strconn1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\data\;Extended Properties=Paradox 5.x;";<br/>
String query = "select * from logdetails";<br/>
try<br/>
{<br/>
cmd = new OleDbCommand(query);<br/>
cmd.CommandType = CommandType.Text;<br/>
<br/>
da.SelectCommand = (OleDbCommand)cmd;<br/>
<br/>
connection = new OleDbConnection(strconn1);<br/>
cmd.Connection = connection;<br/>
connection.Open();<br/>
// fill the dataset<br/>
da.Fill(ds);<br/>
dataGridView1.DataSource = ds;<br/>
}<br/>
catch<br/>
{<br/>
throw;<br/>
}<br/>
finally<br/>
{<br/>
if (da != null)<br/>
da.Dispose();<br/>
if (cmd != null)<br/>
cmd.Dispose();<br/>
// implicitly calls close()<br/>
connection.Dispose();<br/>
}<br/>
<br/>
}<br/>
}
I got the exception throw at
da.Fill(ds);
The error message is:
OleDbException was unhandled
The Microsoft Jet database engine could not find the object logdetails.
Make sure the object exists and that you spell its name and the path name correctly.
I have checked the table "logdetails.dbf" in that folder:
C:Tempdata
Anything I have done wrong?
All tables have their corresponding .dbf and .cdx files. Are these the problem because there is no .db single file but individual dbf file, or should I use other provider like odbc?
<br/>
View the full article
private void button1_Click(object sender, EventArgs e)<br/>
{<br/>
OleDbConnection connection;<br/>
OleDbCommand cmd;<br/>
OleDbDataAdapter da;<br/>
<br/>
connection = null;<br/>
cmd = null;<br/>
DataSet ds = new DataSet();<br/>
da = new OleDbDataAdapter();<br/>
<br/>
String strconn1 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\data\;Extended Properties=Paradox 5.x;";<br/>
String query = "select * from logdetails";<br/>
try<br/>
{<br/>
cmd = new OleDbCommand(query);<br/>
cmd.CommandType = CommandType.Text;<br/>
<br/>
da.SelectCommand = (OleDbCommand)cmd;<br/>
<br/>
connection = new OleDbConnection(strconn1);<br/>
cmd.Connection = connection;<br/>
connection.Open();<br/>
// fill the dataset<br/>
da.Fill(ds);<br/>
dataGridView1.DataSource = ds;<br/>
}<br/>
catch<br/>
{<br/>
throw;<br/>
}<br/>
finally<br/>
{<br/>
if (da != null)<br/>
da.Dispose();<br/>
if (cmd != null)<br/>
cmd.Dispose();<br/>
// implicitly calls close()<br/>
connection.Dispose();<br/>
}<br/>
<br/>
}<br/>
}
I got the exception throw at
da.Fill(ds);
The error message is:
OleDbException was unhandled
The Microsoft Jet database engine could not find the object logdetails.
Make sure the object exists and that you spell its name and the path name correctly.
I have checked the table "logdetails.dbf" in that folder:
C:Tempdata
Anything I have done wrong?
All tables have their corresponding .dbf and .cdx files. Are these the problem because there is no .db single file but individual dbf file, or should I use other provider like odbc?
<br/>
View the full article