Click here to Skip to main content
15,885,856 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir,madam
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?
Posted
Updated 18-Jan-12 1:16am
v2

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

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



In your Database connection class use this connection string


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

C#
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();
sqlcom0.Fill(ds0);
 
Share this answer
 
Comments
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