Click here to Skip to main content
15,126,501 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created my windows application database in sql server 2008. I have add connection in my server explorer of .net and used successfully. But now I wanted to add database file in my application folder so please tell me how to ADD it?
Updated 18-Jan-12 2:16am

In your web.config/app.config file add ConnectionString

		<remove name="LocalSqlServer" />
		<add name="myConnection" connectionstring="Data Source=MASTER-YODA;Initial Catalog=MyDatabase;User ID=myuserId;Password=mypassword" />

In your Database connection class use this connection string

public string conString = ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString;
SqlConnection con = new SqlConnection(conString);
Try this

string myConnection = "Data Source=DBName;Initial Catalog=DatabaseName;User Id=Userid;Password=Pass@123;";
SqlDataAdapter sqlcom0 = new SqlDataAdapter("SELECT * FROM Employee", myConnection);
DataSet ds0 = new DataSet();
RDBurmon 18-Jan-12 7:14am
try this connection and also if you need any help regarding read, update , insert , delete . do let me know
vishalcbhosale 18-Jan-12 7:23am
sir I wanted to move created database file in sql server 2008 to my .net application folder
RDBurmon 18-Jan-12 7:29am
Why ?

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