Tuesday, October 21, 2014

How to connect to Mysql database in web application using asp.net with 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 connect to Mysql database in web application using asp.net with c#  
 -----------------------------------------------------------------------------  
 //Create MySQLConnection Object  
       MySqlConnection conn = new MySqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["YourConnectionString"].ConnectionString);  
       //Sample Select Query   
       string strSQL = "SELECT ID, FirstName, LastName FROM YourTable";  
       //Open the Connection  
       conn.Open();  
       //Create MySqlDataAdapter object and assign the query and connection to it  
       MySqlDataAdapter mydata = new MySqlDataAdapter(strSQL, conn);  
       //Create MySqlCommandBuilder object  
       MySqlCommandBuilder cmd = new MySqlCommandBuilder(mydata);  
       //Dataset to hold the values  
       DataSet ds = new DataSet();  
       //Fill the data from MYSQL DB  
       mydata.Fill(ds);  
       YourGridView.DataSource = ds;  
       YourGridView.DataBind();  
       //Close the connection  
       conn.Close();  

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


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