Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > Just a Connection String(Database) Question
 

Just a Connection String(Database) Question

SqlConnection SqlCon = new SqlConnection("Server=(local);Database=pubs;Trusted_Connection=True");

hi, this is a working connection string in my project.

Can i in any way specify the location of the database on my pc ,like "location =C:\testdb\..." in the above connection string.(For SQL Server 2008)

Also can we also specify of the location of the .mdf file(or any other) which can then be used to access data.

Sahil Ansari  Saturday, August 15, 2009 1:17 PM
Hi,

Well i got the solution to the abouve problem.Heres for every one



string

constr=@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\\..\\RightAccess.accdb";

just pass this string along with OleDb connection obeject to OleDb command.

I wanted Data Soruce path which was indepedent of the machine.The above one is a relative path , relative to the folder were you have installed the programme.


I believe same works for SqlConnection.


Thanks

Sahil Ansari  Thursday, August 20, 2009 4:05 AM

Do you mean when you deploy the project? Are you using ClickOnce or a Setup & Deployment package?

Or are you speaking generally about how to connect to a database?

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 17, 2009 6:29 AM
Hi,

Well i got the solution to the abouve problem.Heres for every one



string

constr=@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\\..\\RightAccess.accdb";

just pass this string along with OleDb connection obeject to OleDb command.

I wanted Data Soruce path which was indepedent of the machine.The above one is a relative path , relative to the folder were you have installed the programme.


I believe same works for SqlConnection.


Thanks

Sahil Ansari  Thursday, August 20, 2009 4:05 AM

You might want to post your question in the C# forum next time. This is a forum for the deployment of .Net applications.

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Thursday, August 20, 2009 5:18 AM
OK, did not realise that
Sahil Ansari  Thursday, August 20, 2009 7:41 AM
It's okay. You just tend to get help faster if you post in the right forum. :-)

Robin
Click here to visit my ClickOnce blog!
RobinDotNet  Thursday, August 20, 2009 9:33 AM

You can use google to search for other answers

Custom Search

More Threads

• ParseException on manifest when installing ClickOnce App
• SQLExpress can't attach Database using ClickOnce
• Specify Installation Location for ClickOnce deployment
• Receiving UI selection with radio buttons
• Detaching Database - error during uninstall
• Proxy settings for clickonce
• Set-up for a class library
• Deploying SQL Server 2008 Database (not the app) with a Windows Application
• ClickOnce error while starting setup
• Is there a comprehensive tutorial somewhere on Setup Projects