Click here to Skip to main content
15,903,816 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I m using C# windows base application where I m getting problem for connection
My application path is
C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\Test Crystal Report

And data base path is
C:\Documents and Settings\Administrator\Desktop\Product.mdb

Code I wrote is
private OleDbConnection conn = new OleDbConnection();
private String ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + ";Persist Security Info=False;";

how to write the connection for application path and database path please help

Thanks & Regards
Indrajit
Posted
Updated 21-Jun-11 20:06pm
v2

Add your database to your server explorer and get the connection string from its properties.
 
Share this answer
 
you can use Application.UserAppDataPath[^] for this purpose. You need to place your mdb in the respective folder. go throgh the url you will find all the details and sample.
 
Share this answer
 
Place your database in bin/Debug folder then access it like this ==>


C#
private String ConStr = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=Product.mdb;Persist Security Info=False;";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900