First time to use oledbconnection, but I failed. :(
-
1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?
-
1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?
You have three options:
- If you're connecting to SQL Server, you could use the SQLConnection and related objects in the System.Data.SqlClient namespace;
- If you really need an OLEDB connection, use the OLE DB Provider for SQL Server (SQLOLEDB.1), or the equivalent for your data source;
- If you absolutely must have an ODBC connection, you need to download the ODBC provider for .Net and use that instead;
-
1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?
-
You have three options:
- If you're connecting to SQL Server, you could use the SQLConnection and related objects in the System.Data.SqlClient namespace;
- If you really need an OLEDB connection, use the OLE DB Provider for SQL Server (SQLOLEDB.1), or the equivalent for your data source;
- If you absolutely must have an ODBC connection, you need to download the ODBC provider for .Net and use that instead;
-
1.Choose "Microsoft OLE DB Provider for ODBC Drivers" 2.Choose "Use data source name" and select a alias from drop list.( The alias has no password) 3.Click "OK" button, but it shows "The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL Provider, Microsoft OLE DB Provider for ODBC Drivers.".:confused: Thank you for your help! I'm amumu, and you?
-
Thank you. But I think the oleDbConnection should work properly when I do the steps as above, why does it reports error? I'm amumu, and you?
The objects in System.Data.OleDb do not support ODBC connections, so you can't use the OLE DB Provider for ODBC. You have to use the ODBC .Net Provider to access an ODBC data source.
-
Either read the data in a OleDbDataReader or a OleDbDataAdapter. EG
//Common code
string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
accessConn = new OleDbConnection(jetConn);
string query = "SELECT * FROM TABLE WHERE etc etc";//Reader
OleDbCommand myCommand = new OleDbCommand(query, accessConn);
OleDbDataReader myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
string datain = myReader.GetString(0); // gets string from column 0
}//OR DataAdapter
DataTable dt = new DataTable(); //can use DataSet as well
OleDbDataAdapter sda = new OleDbDataAdapter(query, accessConn);
sda.Fill(dt);Hope this helps :-D
-
Either read the data in a OleDbDataReader or a OleDbDataAdapter. EG
//Common code
string jetConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\tracker.mdb";
accessConn = new OleDbConnection(jetConn);
string query = "SELECT * FROM TABLE WHERE etc etc";//Reader
OleDbCommand myCommand = new OleDbCommand(query, accessConn);
OleDbDataReader myReader = myCommand.ExecuteReader();
while(myReader.Read())
{
string datain = myReader.GetString(0); // gets string from column 0
}//OR DataAdapter
DataTable dt = new DataTable(); //can use DataSet as well
OleDbDataAdapter sda = new OleDbDataAdapter(query, accessConn);
sda.Fill(dt);Hope this helps :-D