{"id":97,"date":"2010-05-09T08:00:00","date_gmt":"2010-05-09T00:00:00","guid":{"rendered":"http:\/\/31.0.2.219:81\/?p=97"},"modified":"2014-03-11T16:50:11","modified_gmt":"2014-03-11T08:50:11","slug":"vb%e8%bf%9e%e6%8e%a5sql%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84%e6%a8%a1%e5%9d%97%e4%bb%a5%e5%8f%8a%e4%bd%bf%e7%94%a8%e5%ae%9e%e4%be%8b","status":"publish","type":"post","link":"http:\/\/www.huike007.cn\/?p=97","title":{"rendered":"vb\u8fde\u63a5sql\u6570\u636e\u5e93\u7684\u6a21\u5757\u4ee5\u53ca\u4f7f\u7528\u5b9e\u4f8b"},"content":{"rendered":"<p>\u6253\u5f00VB6.0,\u65b0\u5efa\u5de5\u7a0bSQL_data,\u65b0\u5efa\u4e00\u4e2aEXE\uff0c\u5e76\u6dfb\u52a0\u4e00\u4e2a\u6a21\u5757\u3002\u5982\u56fe<br \/>\n\u3002<img src=\"download.asp?id=9\" border=\"0\" alt=\"\"\/><br \/>\n<img src=\"download.asp?id=10\" border=\"0\" alt=\"\"\/><br \/>\n\u4e00\uff1a\u6dfb\u52a0\u5f15\u7528\u548c\u90e8\u4ef6\uff08\u5982\u4e0b\u4e24\u56fe\uff09\u84dd\u8272\u7684\u4e24\u4e2a\uff0c\u662f\u8981\u9009\u4e2d\u6253\u52fe\u7684\u3002<br \/>\n\u6ce8\u610f\uff0c\u4e00\u4e2a\u662f\u201c\u5f15\u7528\u201d\uff0c\u4e00\u4e2a\u662f\u201c\u90e8\u4ef6\u201d\u3002<br \/>\n<img src=\"download.asp?id=11\" border=\"0\" alt=\"\"\/><br \/>\n<img src=\"download.asp?id=12\" border=\"0\" alt=\"\"\/><br \/>\n              \u4e8c\uff1a\u6dfb\u52a0\u4e00\u4e2a\u6a21\u5757 Data_Sql\uff0c\u5e76\u628a\u56fe\u4e0b\u9762\u7684\u590d\u5236\u7c98\u8d34\u5230\u6a21\u5757\u4e2d\u3002               &#39;\u8fde\u63a5SQL\u7684\u6a21\u5757<br \/>\nPublic conn As ADODB.Connection<br \/>\nPublic rs As ADODB.Recordset<br \/>\nPublic addFlag As Boolean      &#39;\u58f0\u660e\u90e8\u5206<br \/>\nPublic Function OpenCn(ByVal Cip As String, ByVal users As String, ByVal pw As String) As Boolean &#39;\u8fde\u63a5\u6a21\u5757 \u586b\u5199\u6570\u636e\u5e93\u7b49\u4fe1\u606f<br \/>\nDim mag As String<br \/>\nOn Error GoTo strerrmag<br \/>\nSet conn = New ADODB.Connection<br \/>\nconn.ConnectionTimeout = 25<br \/>\nconn.Provider = &#34;sqloledb&#34;<br \/>\nconn.Properties(&#34;data source&#34;).Value = Cip     &#39;\u670d\u52a1\u5668\u7684\u540d\u5b57<br \/>\nconn.Properties(&#34;initial catalog&#34;).Value = &#34;pubs&#34;          &#39;\u5e93\u540d<br \/>\n&#39;conn.Properties(&#34;integrated security&#34;).Value = &#34;SSPI&#34;      &#39;\u767b\u9646\u7c7b\u578b<br \/>\nconn.Properties(&#34;user id&#34;).Value = users &#39;SQL\u5e93\u540d<br \/>\nconn.Properties(&#34;password&#34;).Value = pw &#39;\u5bc6\u7801<br \/>\n&#39;sql = &#34;Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;password=;Initial Catalog=pubs;Data Source=127.0.0.1&#34;    &#39;\u5982\u679c\u4e0d\u7528\u8fd9\u4e2a\u6a21\u5757\u4e5f\u884c\u53ef\u4ee5\uff0c\u8fd9\u4e00\u53e5\u4fbf\u662f\u5e38\u7528\u7684\u5f15\u64ce\u3002<br \/>\n&#39;conn.ConnectionString = sql<br \/>\nconn.Open<br \/>\nOpenCn = True<br \/>\nIf conn.State = 1 Then addFlag = True<br \/>\nExit Function<br \/>\nstrerrmag:<br \/>\n     mag = &#34;Data can&#39;t connect&#34;<br \/>\n     Call MsgBox(mag, vbOKOnly, &#34;Error:Data connect&#34;)<br \/>\n     addFlag = False<br \/>\n     Exit Function      &#39;\u8fde\u63a5\u9519\u8bef\u6d88\u606f<br \/>\nEnd Function<br \/>\n&#39;\u5173\u95ed\u6570\u636e\u5e93\uff0c\u91ca\u653e\u8fde\u63a5<br \/>\nPublic Sub cloCn()<br \/>\nOn Error Resume Next<br \/>\nIf conn.State &lt;&gt; adStateClosed Then conn.Close<br \/>\nSet conn = Nothing<br \/>\nEnd Sub<br \/>\nPublic Function openRs(ByVal strsql As String) As Boolean      &#39;\u8fde\u63a5\u6570\u636e\u5e93\u8bb0\u5f55\u96c6<br \/>\nDim mag As String<br \/>\nDim rpy As Boolean<br \/>\nOn Error GoTo strerrmag<br \/>\n     Set rs = New ADODB.Recordset<br \/>\n     If addFlag = False Then rpy = True<br \/>\n     With rs<br \/>\n     .ActiveConnection = conn<br \/>\n     .CursorLocation = adUseClient<br \/>\n     .CursorType = adOpenKeyset<br \/>\n     .LockType = adLockOptimistic<br \/>\n     .Open strsql<br \/>\n     End With<br \/>\n     addFlag = True<br \/>\n     openRs = True<br \/>\n     &#39;End        &#39;\u5c06\u8bb0\u5f55\u96c6\u7ed9rs<br \/>\n     Exit Function<br \/>\nstrerrmag:<br \/>\n     mag = &#34;data not connect&#34;<br \/>\n     Call MsgBox(mag, vbOKOnly, &#34;error:connect&#34;)<br \/>\n     openRs = False<br \/>\n     End<br \/>\n     &#39;Exit Function &#39;\u8fde\u63a5\u9519\u8bef\u6d88\u606f<br \/>\nEnd Function<br \/>\nPublic Sub cloRs()<br \/>\nOn Error Resume Next<br \/>\nIf rs.State &lt;&gt; adStateClosed Then rs.Clone<br \/>\nSet rs = Nothing &#39;\u91ca\u653e\u8bb0\u5f55\u96c6<br \/>\nEnd Sub<br \/>\n\u628a\u5b83\u653e\u5165\u5230\u6a21\u5757\u6587\u4ef6\u4e2d\uff0c\u4ee5\u5907\u8c03\u7528\u3002<br \/>\n\u4e09\uff1a\u4e0b\u9762\u4e24\u56fe\u662f\u6a21\u5757\u7684\u4ee3\u7801\u56fe\u7247\u548c\u7a97\u4f53\u7684\u4ee3\u7801\u56fe\u7247<br \/>\n<img src=\"download.asp?id=13\" border=\"0\" alt=\"\"\/><br \/>\n<img src=\"download.asp?id=14\" border=\"0\" alt=\"\"\/><br \/>\n       Private Sub Command1_Click()<br \/>\na = Trim(Text1.Text)<br \/>\nb = Trim(Text2.Text)<br \/>\nc = Trim(Text3.Text)<br \/>\nCall OpenCn(a, b, c)<br \/>\nIf addFlag = True Then MsgBox (&#34;OK&#34;)<br \/>\nCall openRs(&#34;sel&#101;ct * from jobs&#34;)<br \/>\nSet DataGrid1.DataSource = rs<br \/>\n&#39;rs.Close<br \/>\nEnd SubPrivate Sub Command2_Click()<br \/>\nUnload Me<br \/>\nEnd Sub<br \/>\n\u56db\uff1a\u8fd0\u884c\u65f6\u7684\u56fe\u7247\uff08\u4e0b\u9762\u4e24\u56fe\uff09    \u5230\u4e86\u8fd9\u4e00\u6b65\uff0c\u4e00\u4e2a\u7b80\u5355\u7684VB\u8fde\u63a5SQL\u7684\u4f8b\u5b50\u5c31\u5b8c\u6210\u4e86<br \/>\n<img src=\"download.asp?id=15\" border=\"0\" alt=\"\"\/><br \/>\n<img src=\"download.asp?id=16\" border=\"0\" alt=\"\"\/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6253\u5f00VB6.0,\u65b0\u5efa\u5de5\u7a0bSQL_data,\u65b0\u5efa\u4e00\u4e2aEXE\uff0c\u5e76\u6dfb\u52a0\u4e00\u4e2a\u6a21\u5757\u3002\u5982\u56fe \u3002 \u4e00\uff1a\u6dfb\u52a0\u5f15\u7528\u548c\u90e8\u4ef6\uff08\u5982\u4e0b\u4e24 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[181],"tags":[311,227],"_links":{"self":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/97"}],"collection":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=97"}],"version-history":[{"count":1,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":345,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=\/wp\/v2\/posts\/97\/revisions\/345"}],"wp:attachment":[{"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.huike007.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}