views:

1148

answers:

2

Hai

i want oledb connection using Dsn. I used the following code

'Dsn Create
 dbRegBase.RegisterDatabase("GEMINI", "Microsoft Access Driver (*.mdb)", True,DBQ=D:\Gemini\GEMINI\database\paints_01_2008-2009.mdb
Description=Greenchip Technologies ODBC Database File Path
OemToAnsi=No
UID=admin
PWD=XXXXXX

conection code
Provider=Microsoft.Jet.OLEDB.4.0;DBQ ='GEMINI';Persist Security Info=False;Jet OleDB:Database Password = XXXXXX

But Error come error name is "Could not find installable ISAM" what i do . please tell me.

A: 

Does it need to be an OleDB connection?

I tried using OleDB in my most recent application and failed miserably but managed using and OdbcConnection and DSN.

String query = "SELECT * FROM myTable"; //Complete this for your specific query
OdbcConnection con = new OdbcConnection("DSN=DatabaseName");
OdbcCommand com = new OdbcCommand("Query...", con);
try
{
    con.Open();
    OdbcReader reader = com.ExecuteReader();

    while(reader.Read())
    {
        //Do things with the results
    }
}
catch(Exception ex)
{
    //Exception handling
}

A lot friendlier than using OleDB I think.

Bailz
your code come error
somu
You'll need to add in the DatabaseName to the DSN and create a proper query to create the OdbcCommand with. You'll also need an OdbcDataReader in order to read what you've queried.
Bailz
A: 

My question is why would anyone want to use odbc? There are many sites out there that show the speed improvements of oledb vs odbc. Also, odbc has not been updated in a while and is very buggy.

Jamie R Rytlewski
Which is better depends entirely on what development platform you're connecting to the database from, and how you're using it. As well as what drivers are available. And, also, OLEDB is problematic in that the interfaces to it (ADO and ADO.NET) are not usable in all cases. Also, in the case of an Access file, OLEDB cannot accept a database password, so if you have a password-protected MDB/ACCDB, you have to use ODBC.
David-W-Fenton