Tuesday, October 21, 2014

How to establish sql database Connection using c#

Posted by Gnani Palepu  |  No comments


 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  

 How to establish sql database Connection using c#?  
 protected void Button1_Click(Object sender,EventArgs e)  
 {  
 string Text1=TextBox1.Text;  
 string Text2=TextBox2.Text;  
 string connectionString="Data Source=servername;InitialCatalog=DataBaseNameUserID=sa; Password=YourPassword;"  
 SqlConnection sqlConnection=new SqlConnection(connectionString);  
 string insertStatement="INSERT INTO TableName(column1,column2) VALUES Txtb1+","+Txtb2";  
 SqlCommand sqlCommand=new SqlCommand(insertStatement,sqlConnection);  
 try  
 {  
 sqlConnection.Open();  
 sqlCommand.ExecuteNonQuery();  
 }  
 finally  
 {  
 sqlConnection.Close();  
 }  
 }  

 if you want more related search please click here  
 please help to other  
 http://scriptquery.blogspot.in/  


6:27 AM Share:

0 comments:

Get updates in your email box
Complete the form below, and we'll send you the best coupons.

Deliver via FeedBurner
Proudly Powered by Blogger.
back to top