Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello

 

I'm building an application with a connection to a MDB database (access).

I've build the code like this:

 

            IniFile ini = new IniFile("test.ini");
           database = ini.IniReadValue("Info", "Database");
           connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + database + ";User Id=admin;Password=;";
           SqlConnection cn = new SqlConnection(connectionString);
           string sCommand = "select * from Klanten";

 

But i'll get an error.. .Net said that the string is not correct.

On an other part of the program i use this code:

 

database = ini.IniReadValue("Info","Database");

connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;"; 
connectionString += @"Data Source=" + database + ";"; 

Connection.ConnectionString = connectionString;
Connection.Open();	

 

That last part works !!

 

But why the first not ?

Wats wrong.. database contains the full path to the database like: c:\database.mdb

Posted

In the first example you are useing an UserId.

Are you sure the db needs it?

 

If the second ConString is working remove the user/pwd from the firstone.

Posted
In the first example you are useing an UserId.

Are you sure the db needs it?

 

If the second ConString is working remove the user/pwd from the firstone.

 

Doesnt mather.. i'll get this error:

 

Keyword not supported :'provider'

 

On this line:

 

SqlConnection cn = new SqlConnection(connectionString);

  • 3 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...