Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I add the Sqlconnection component into the form & my .mdf data file have locate in my particular location.

I want to do that, i connect the database .mdf file (server2008 r2) through Sqlconnection component by design wizard.

How will i connect that .mdf file through describing ????

Please help me any instruction.....
Posted
Comments
[no name] 2-Aug-12 9:34am    
"How will i connect that .mdf file through describing"... makes no sense. Can you be more clear?

1 solution

Connectionstrings.com[^] is always a good place to start

Attach a database file, located in the data directory, on connect to a local SQL Server Express instance
Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf; Database=dbname;Trusted_Connection=Yes;

Why is the Database parameter needed? If the named database have already been attached, SQL Server does not reattach it. It uses the attached database as the default for the connection.


is something that I would have a look at but I'm not sure if it will work if the database server is on a remote machine
 
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