{"id":34,"date":"2008-07-22T22:19:08","date_gmt":"2008-07-22T22:19:08","guid":{"rendered":"http:\/\/kumouse.aafox.com\/?p=34"},"modified":"2008-07-22T22:19:08","modified_gmt":"2008-07-22T22:19:08","slug":"delphi2006-dbexpress-%e8%bf%9e%e6%8e%a5-mysql5-1","status":"publish","type":"post","link":"https:\/\/www.kumouse.com\/?p=34","title":{"rendered":"Delphi2006 DBExpress \u8fde\u63a5 Mysql5.1"},"content":{"rendered":"<p>DBExpress\uff0bdbxopenmysql50.dll<\/p>\n<p>\u7531\u4e8eDelphi2006\u4e2d\u7684DBExpress\u5bf9Mysql\u9ad8\u7248\u672c\u7684\u652f\u6301\u5f88\u5dee\uff0c\u4ece\u56fd\u5916\u8bba\u575b\u4e0a\u770b\u5230\u7684\u8bf4\u6cd5\u4f3c\u4e4e\u662f\u6839\u672c\u5c31\u6ca1\u5b9e\u73b0\uff0c\u6240\u4ee5\u8bf4\u867d\u7136TSQLConnection\u7ec4\u4ef6\u4e2d\u63d0\u4f9b\u4e86Mysql\u9009\u9879\uff0c\u4f46\u76f4\u63a5\u4f7f\u7528\u7684\u8bdd\u662f\u4e0d\u884c\u7684\uff08\u4f4e\u7248\u672c\u7684mysql\u53ef\u80fd\u53ef\u4ee5\uff09\uff0c\u6211\u9047\u5230\u7684\u73b0\u8c61\u662f\u63d0\u793a\u201cUnable to Load libmysql.dll\u201d\uff0c\u4f46\u5176\u5b9e\u6211\u5df2\u7ecf\u5728\u7cfb\u7edf\u76ee\u5f55System32\u4e0b\u3001Delphi\u5b89\u88c5\u76ee\u5f55\u7684bin\u4e2d\u3001\u5f00\u53d1\u5de5\u7a0b\u9879\u76ee\u6587\u4ef6\u5939\u4e2d\u90fd\u5b89\u653e\u4e86\u8be5\u6587\u4ef6\uff0c\u8fd8\u662f\u627e\u4e0d\u5230\u8be5dll\u3002 <br \/>dbxopenmysql50.dll\u662f\u7531\u8001\u5916\u5f00\u53d1\u7684\uff0c\u800c\u4e14\u5f00\u6e90\uff0c\u8fd8\u662f\u8001\u5916\u597d\u554a\uff0c\u53ef\u4ee5\u5230\u5982\u4e0b\u7f51\u5740\u53bb\u4e0b\u8f7d\uff1a <br \/>http:\/\/www.justsoftwaresolutions.co.uk\/delphi\/dbexpress_and_mysql_5.html <br \/>\u4f7f\u7528\u65f6\u9700\u8981\u5c06dbxopenmysql50.dll\u548clibmysql.dll\u90fd\u653e\u5230\u5de5\u7a0b\u6587\u4ef6\u5939\u4e0b\u3002\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0clibmysql.dll\u5728mysql\u5b89\u88c5\u76ee\u5f55\u4e0b\u7684libopt\u76ee\u5f55\u4e2d\u3002 <br \/>\u4f7f\u7528\u65b9\u6cd5\u6709\u4e24\u79cd\uff0c\u4e00\u79cd\u662f\u76f4\u63a5\u4fee\u6539BorlandBDS4.0dbExpress\u4e0b\u7684dbxdrivers.ini\uff0c\u8c03\u6574\u5176\u4e2d\u5173\u4e8emysql\u7684\u5404\u53c2\u6570\u3002 <br \/>\u53e6\u4e00\u79cd\u5c31\u662f\u5728\u7a0b\u5e8f\u4e2d\u6307\u5b9a\uff0c\u73b0\u5728\u6211\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u4e3a\u4f8b\u8bf4\u660e\u8fd9\u79cd\u8fde\u63a5\u65b9\u5f0f\u7684\u5f00\u53d1\u65b9\u6cd5\u3002 <br \/>\u5728Form\u4e0a\u653e\u4e0aTSQLConnection\u3001TSQLQuery\u3001TStringGrid\u30013\u4e2aTButton\u3001TLable\u3002<\/p>\n<p>\u5728FormCreate\u4e8b\u4ef6\u4e2d\uff1a <br \/>SQLConnection1 := TSQLConnection.Create(nil); <br \/>SQLConnection1.DriverName := &#39;dbxmysql&#39;; <br \/>SQLConnection1.GetDriverFunc := &#39;getSQLDriverMYSQL50&#39;; <br \/>SQLConnection1.LibraryName := &#39;dbxopenmysql50.dll&#39;; <br \/>SQLConnection1.VendorLib := &#39;libmysql.dll&#39;; <br \/>SQLConnection1.LoginPrompt := false; <br \/>\u5728\u6b64\u8bbe\u7f6eTSQLConnection\u7684\u5404\u4e2a\u5177\u4f53\u53c2\u6570\uff0c\u5f53\u7136\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728\u7ec4\u4ef6\u5c5e\u6027\u9762\u677f\u4e2d\u4fee\u6539\uff0c\u6216\u8005\u4fee\u6539dbxdrivers.ini\u4e2d\u7684\u5bf9\u5e94\u53c2\u6570\uff0c\u65b9\u6cd5\u662f\u591a\u79cd\u7684\u3002 <br \/>Connect\u6309\u94ae\u7684\u4e8b\u4ef6\uff1a <br \/>SQLConnection1.Params.Append(&#39;Database=user&#39;); <br \/>SQLConnection1.Params.Append(&#39;User_Name=mysql&#39;); <br \/>SQLConnection1.Params.Append(&#39;Password=mysql&#39;); <br \/>SQLConnection1.Params.Append(&#39;HostName=localhost&#39;); <br \/>SQLConnection1.Open; <br \/>if SQLConnection1.Connected = true then <br \/>Label1.Caption := &#39;success&#39; <br \/>else <br \/>Label1.Caption := &#39;fail&#39;; <br \/>\u8bbe\u7f6e\u6570\u636e\u5e93\u8fde\u63a5\u7684\u5404\u53c2\u6570\u914d\u7f6e\u540e\uff0c\u6253\u5f00\u6570\u636e\u5e93\u8fde\u63a5\uff0c\u540c\u65f6\u663e\u793a\u8fde\u63a5\u662f\u5426\u6210\u529f\u3002 <br \/>Query\u6309\u94ae\u7684\u4e8b\u4ef6\uff1a <br \/>var <br \/>i,j: Integer; <br \/>begin <br \/>SQLQuery1.SQL.Clear; <br \/>SQLQuery1.SQL.Add(&#39;SELECT * FROM userinfo&#39;); <br \/>SQLQuery1.Active := true; <br \/>i := 0; <br \/>SQLQuery1.First; <br \/>while not SQLQuery1.eof do <br \/>begin <br \/>for j:=0 to SQLQuery1.FieldCount-1 do <br \/>StringGrid1.cells[j,i]:=SQLQuery1.Fields[j].AsString; <br \/>SQLQuery1.next; <br \/>inc(i); <br \/>end; <br \/>SQLQuery1.Active := false; <br \/>\u67e5\u8be2\u8868\u6570\u636e\u5e76\u5728StringGrid\u4e2d\u8f93\u51fa\u3002 <br \/>Disconnect\u6309\u94ae\u7684\u4e8b\u4ef6\uff1a <br \/>if SQLConnection1.Connected = true then <br \/>SQLConnection1.Close; <br \/>FormDestroy\u4e8b\u4ef6\uff1a <br \/>if SQLConnection1.Connected = true then <br \/>SQLConnection1.Close; <br \/>SQLConnection1.Free; <br \/>\u8fd0\u884c\u7a0b\u5e8f\uff0c\u70b9\u51fbconnect\u6309\u94ae\uff0c\u5982\u679c\u6570\u636e\u5e93\u8fde\u63a5\u6210\u529f\u53ef\u4ee5\u770b\u5230success\u63d0\u793a\uff0c\u7136\u540e\u70b9\u51fbquery\u6309\u94ae\u5c31\u80fd\u67e5\u8be2\u5230\u8868\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<p>\u4e0b\u8f7d(dbxopenmysql50.dll)<br \/><a href=\"uploads\/200807\/22_222246_dbxopenmysql5_dll.rar\" title=\"uploads\/200807\/22_222246_dbxopenmysql5_dll.rar\" target=\"_blank\">\u70b9\u51fb\u4e0b\u8f7d<\/a><br \/>\u4e0b\u8f7d(dbxopenmysql50.dll\u6e90\u7801)<br \/><a href=\"uploads\/200807\/22_222632_dbxopenmysql5_source.rar\" title=\"uploads\/200807\/22_222632_dbxopenmysql5_source.rar\" target=\"_blank\">\u70b9\u51fb\u4e0b\u8f7d<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>DBExpress\uff0bdbxopenmysql50.dll \u7531\u4e8eDelphi2006\u4e2d\u7684DBExpress\u5bf9My [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-delphi"],"_links":{"self":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":0,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}