Tuesday, October 21, 2014

How to connect the SQL database from C#

Posted by Gnani Palepu  |  No comments


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

 string connectionString = "server=(local)\SQLExpress;database=Northwind;integrated Security=SSPI;";  
 using(SqlConnection _con = new SqlConnection(connectionString))  
 {  
   string queryStatement = "SELECT TOP 5 * FROM dbo.Customers ORDER BY CustomerID";  
   using(SqlCommand _cmd = new SqlCommand(queryStatement, _con))  
   {  
    DataTable customerTable = new DataTable("Top5Customers");  
    SqlDataAdapter _dap = new SqlDataAdapter(_cmd);  
    _con.Open();  
    _dap.Fill(customerTable);  
    _con.Close();  
   }  
 }  

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


6:50 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