{"id":316093,"date":"2024-01-17T07:30:13","date_gmt":"2024-01-16T23:30:13","guid":{"rendered":"https:\/\/www.idc.net\/help\/316093\/"},"modified":"2024-01-17T07:30:13","modified_gmt":"2024-01-16T23:30:13","slug":"asp-net%e8%bf%9e%e6%8e%a5mysql%e7%9a%84%e6%ad%a3%e7%a1%ae%e6%93%8d%e4%bd%9c%e6%b5%81%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/316093\/","title":{"rendered":"asp.net\u8fde\u63a5MySQL\u7684\u6b63\u786e\u64cd\u4f5c\u6d41\u7a0b"},"content":{"rendered":"<p>\u4ee5\u4e0b\u7684\u6587\u7ae0\u4e3b\u8981\u63cf\u8ff0\u7684\u662fasp.net\u8fde\u63a5MySQL \uff0c\u6211\u524d\u4e24\u5929\u5728\u76f8\u5173\u7f51\u7ad9\u770b\u89c1\u7684\u8d44\u6599\uff0c\u89c9\u5f97\u633a\u597d\uff0c\u5c31\u62ff\u51fa\u6765\u4f9b\u5927\u5bb6\u5206\u4eab\u3002\u4ee5\u4e0b\u5c31\u662f\u6587\u7ae0\u5bf9asp.net\u8fde\u63a5MySQL \u8be6\u7ec6\u5185\u5bb9\u4ecb\u7ecd\uff0c\u5e0c\u671b\u5728\u4f60\u4eca\u540e\u7684\u5b66\u4e60\u4e2d\u4f1a\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u6700\u8fd1\u5c1d\u8bd5\u4f7f\u7528asp.net 1.1\u8fde\u63a5MySQL\uff0c\u539f\u6765\u53d1\u73b0MySQL\u672c\u8eab\u5c31\u63d0\u4f9b\u4e86provider(http:\/\/www.MySQL.com\/products\/connector\/net\/),<\/p>\n<p>\u5230\u4e0a\u9762\u7684\u5730\u5740\u4e0b\u8f7d\u4e86\uff0c\u4e4b\u540eSETUP\u5b89\u88c5\uff0c\u5341\u5206\u7b80\u5355\uff0c\u672c\u8eab\u4e5f\u5e26SAMPLE\u7684\u3002<\/p>\n<p>\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u5148\u6839\u636e\u7248\u672c\uff08\u76ee\u524d\u63d0\u4f9bFOR \u3002NET 1.0,1.1\u7248\u672c\u7684\uff09\u5f15\u7528\u5176DLL\uff0c\u4e4b\u540e\u7b80\u5355\u4ee3\u7801\u5982\u4e0b\uff0c\u548c\u666e\u901a\u7684\u7528data.sqlclient\u5dee\u4e0d\u591a\u3002<\/p>\n<pre>\n \n \n \n <ol>\n  \n  \n  \n  <li><span>using&nbsp;MySQL.Data.<\/span>MySQL<span>Client;&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li><span>........&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li>MySQL<span>Connection&nbsp;<\/span><span>myConnection<\/span><span>=<\/span><span>new<\/span><span>&nbsp;<\/span>MySQL<span>Connection(\"<\/span><span>server<\/span><span>=<\/span><span>localhost<\/span><span>;user&nbsp;<\/span><span>id<\/span><span>=<\/span><span>root<\/span><span>;<\/span><span>password<\/span><span>=<\/span><span>XXXX<\/span><span>;<\/span><span>database<\/span><span>=<\/span><span>baby<\/span><span>\");&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li><span>string&nbsp;<\/span><span>sql<\/span><span>=<\/span><span>\"select&nbsp;*&nbsp;from&nbsp;admin\"<\/span><span>;&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li>MySQL<span>DataAdapter&nbsp;<\/span><span>myda<\/span><span>=<\/span><span>new<\/span><span>&nbsp;<\/span>MySQL<span>DataAdapter(sql,myConnection);&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li><span>DataSet&nbsp;<\/span><span>mydataset<\/span><span>=<\/span><span>new<\/span><span>&nbsp;DataSet();&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li><span>myda.Fill(mydataset,\"admin\");&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li><span>mydatagrid.DataSource<\/span><span>=<\/span><span>mydataset<\/span><span>;&nbsp; &nbsp;<\/span><\/li>\n  \n  \n  \n  <li><span>mydatagrid.DataBind();&nbsp; &nbsp;<\/span><\/li>\n \n \n \n <\/ol><\/pre>\n<p>\u662f\u4e0d\u662f\u5f88\u7b80\u5355\u5462\uff1f<\/p>\n<p style=\"text-align: center\"> &nbsp;<\/p>\n<p style=\"text-align: left\">\u4ee5\u4e0a\u7684\u76f8\u5173\u5185\u5bb9\u5c31\u662f\u5bf9asp.net\u4e2d\u8fde\u63a5MySQL \u7684\u4ecb\u7ecd\uff0c\u671b\u4f60\u80fd\u6709\u6240\u6536\u83b7\u3002<\/p>\n<p>\u3010\u7f16\u8f91\u63a8\u8350\u3011<\/p>\n<ol>\n<li>\u5982\u4f55\u7528PHP\u6765\u5b9e\u73b0MySQL\u5907\u4efd?<\/li>\n<li>MySQL\u8f6c\u4e49\u5b57\u7b26\u7684\u5b9e\u9645\u5e94\u7528<\/li>\n<li>\u5bf9MySQL\u6570\u636e\u5e93\u4e2d\u7684\u547d\u4ee4\u5907\u5fd8\u63cf\u8ff0<\/li>\n<li>MySQL\u5e38\u7528\u6280\u5de7\u90fd\u5305\u62ec\u54ea\u4e9b\uff1f<\/li>\n<li>MySQL \u5907\u4efd\u7684\u5b9e\u9645\u5e94\u7528\u4e0e\u529f\u80fd\u4ecb\u7ecd<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u7684\u6587\u7ae0\u4e3b\u8981\u63cf\u8ff0\u7684\u662fasp.net\u8fde\u63a5MySQL \uff0c\u6211\u524d\u4e24\u5929\u5728\u76f8\u5173\u7f51\u7ad9\u770b\u89c1\u7684\u8d44\u6599\uff0c\u89c9\u5f97\u633a\u597d\uff0c\u5c31\u62ff\u51fa\u6765\u4f9b\u5927\u5bb6\u5206 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":316094,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7038],"tags":[],"class_list":["post-316093","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/316093","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=316093"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/316093\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/316094"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=316093"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=316093"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=316093"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}