In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "the problems and solutions encountered when ADO.NET connects MySQL". In the daily operation, I believe that many people have doubts about the problems and solutions encountered when ADO.NET connects MySQL. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions and solutions encountered when ADO.NET connects MySQL. Next, please follow the editor to study!
When learning ADO.NET, you may encounter the problem of connecting ADO.NET to MySQL. Here we will introduce the solution to the problem of connecting ADO.NET to MySQL, and share it with you here. After Mysql is installed, click Properties, and then click to find the target, click up to the directory, find Binaries\ .NET2.0, and then copy this file to your project directory. Generally, such DLL files will be saved to the bin directory. Type usingMysql.Data.MysqlClient; in the code page and then write MysqlConnection in the Page_Load function. The prompt will come out in the middle of the word, so you don't have to write the following, right? Have already appeared "code intelligence is completed", just write a piece of code to try, just like Sqlserver.
The following provides two pieces of code for reference, one code page and one HTML page: ADO.NET connection MySQL code under default2.aspx.cs:
UsingSystem; usingSystem.Data; usingSystem.Configuration; usingSystem.Collections; usingSystem.Web; usingSystem.Web.Security; usingSystem.Web.UI; usingSystem.Web.UI.WebControls; usingSystem.Web.UI.WebControls.WebParts; usingSystem.Web.UI.HtmlControls; usingMySql.Data.MySqlClient; publicpartialclassDefault2:System.Web.UI.Page {protectedvoidPage_Load (objectsender,EventArgse) {stringquery= "select*fromguestbook"; MySqlConnectionmyConnection=newMySqlConnection ("server=localhost;userid=root;password=;database=guestbook"); MySqlCommandmyCommand=newMySqlCommand (query,myConnection); myConnection.Open () MyCommand.ExecuteNonQuery (); MySqlDataReadermyDataReader=myCommand.ExecuteReader (); stringbookres= ""; while (myDataReader.Read () = = true) {bookres+=myDataReader ["id"]; bookres+=myDataReader ["user"]; bookres+=myDataReader ["pass"];} myDataReader.Close (); myConnection.Close (); lb1.Text=bookres;}}
Code under default2.aspx
Untitled page
The above results pass the test under visualwebDeveloper2005 (express version)! I believe it can also be passed in visualstudio2005!
At this point, the study on "the problems and solutions encountered when ADO.NET connects to MySQL" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.