sunDAC

i am working on microsoft acess database.I want to create coneection string.I know one procedure using udl file.

i have a coneection string as

aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\FarmERP\\Data\\FarmERP.mdb;Persist Security Info=True;Jet OLEDBBig Smileatabase Password=sswww");

Please anyone tell me procedure how can i create this type of connection string when i have given password to the database.



Re: Windows Forms Data Controls and Databinding database connectiostring problem

franking

Hi,

did you try System.Data.OleDb.OleDbConnectionStringBuilder

Hope this helps,

franking





Re: Windows Forms Data Controls and Databinding database connectiostring problem

sunDAC

Thanks for u r help.

I am really dont familier with all these things so can u please give me the procedure.

Waiting for u r reply





Re: Windows Forms Data Controls and Databinding database connectiostring problem

franking

sorry for the delay

Try something like the following:

Code Block

...

OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();

builder.PersistSecurityInfo = true;

builder.Provider = "Microsoft.Jet.OLEDB.4.0";

builder.DataSource = "e:\\FarmERP\\Data\\FarmERP.mdb";

builder.Add("Jet OLEDB:Database Password", "sswww");

OleDbConnection conn = new OleDbConnection(builder.ConnectionString);

...

This should create a connection string like the one you have posted.

In order to get this working, please read as much as possible about these classes and best practice solutions.

For a detailed description of connection strings, have a look here:

http://www.connectionstrings.com/ carrier=access

Hope this helps,

franking





Re: Windows Forms Data Controls and Databinding database connectiostring problem

sunDAC

i am really sorry,i cant get it.My problem is that i know

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\mydatabase.mdb;Jet OLEDBTongue Tiedystem Database=system.mdw;User ID=myUsername;Password=myPassword;
But i just dont want to copy and paste it.I want to know the procedure to create this string.
I have one option by using udl file.But when i give password to database it cant work.
So do u have any idea @ it.
Thanks.




Re: Windows Forms Data Controls and Databinding database connectiostring problem

Yu Guo – MSFT

Hi, sunDAC,

I am not sure what do you mean of "the procedure to create this string".

Because we just use this string like this

Code Block

OleDbConnection connection=new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\FarmERP\\Data\\FarmERP.mdb;Persist Security Info=True;Jet OLEDBatabase Password=sswww");

try

{

connection.Open();

//do what you like here

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

finally

{

connection.Close();

}

And what's the error message in your application

Regards






Re: Windows Forms Data Controls and Databinding database connectiostring problem

franking

Ah, ok, guess I know what you mean.

I guess you want something like this.

Code Block

OleDbConnectionStringBuilder builder = new OleDbConnectionStringBuilder();

builder.Provider = OleDbDataProviers.AccessDataProvider;

...

// or some different approach

AccessDbFactory factory = new AccessDbFactory();

OleDbConnectionStringBuilder builder = factory.CreateAccessConnectionStringBuilder();

If this is like what you are looking for, I think there's nothing like that in .NET Framework. Or am I wrong

Maybe you can find a solution on http://www.codeproject.com or a similar site.

Hope this helps,

franking





Re: Windows Forms Data Controls and Databinding database connectiostring problem

Yu Guo – MSFT

We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
Thank you!