VB6.0

VB6.0,第1张

概述Public Function GetConnStr() As String     Dim ConnString As String     ConnString = "Provider = SQLOLEDB.1;Database=IHURALibrary;server=.;uid=Lindy;pwd=sa!12345;"     GetConnStr = ConnString End Func

Public Function GetConnstr() As String
Dim ConnString As String
ConnString = "ProvIDer = sqlolEDB.1;Database=IHURAlibrary;server=.;uID=lindy;pwd=sa!12345;"
GetConnStr = ConnString
End Function

Public Function OpenConn(ByRef Conn As ADODB.Connection) As Boolean
Set Conn = New ADODB.Connection
On Error GoTo ErrorHandle
Conn.Open GetConnStr
OpenConn = True
Exit Function
ErrorHandle:
MsgBox "Á¬½ÓÊý¾Ý¿âʧ°Ü£¡ÇëÖØÐÂÁ¬½Ó"
OpenConn = False
Exit Function
End Function

Public Function Executesql(ByVal sql As String,ByRef msg As String) As String
Dim Conn As ADODB.Connection
On Error GoTo ErrorHandle
If OpenConn(Conn) Then
Conn.Execute sql
msg = "²Ù×÷Ö´Ðгɹ¦£¡"
End If
Executesql = ""
Exit Function
ErrorHandle:
msg = "Ö´ÐдíÎó£º" & Err.Description
Executesql = ""
Set Conn = nothing
Exit Function
End Function

Public Function Selectsql(ByVal sql As String,ByRef msg As String) As ADODB.Recordset
Dim Conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sTokens() As String
On Error GoTo ErrorHandle
sTokens = Split(sql)
If InStr("SELECT",UCase((sTokens(0)))) Then
If OpenConn(Conn) Then
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClIEnt
rs.Open Trim$(sql),Conn,adOpenDynamic,adLockOptimistic
Set Selectsql = rs
msg = "²éѯµ½" & rs.RecordCount & " Ìõ¼Ç¼!"
End If
Else
msg = "sqlÓï¾äÓÐÓï:" & sql
End If
ErrorHandle:
msg = "²éѯ´íÎó£º" & Err.Description
Set rs = nothing
Set Conn = nothing
Exit Function
End Function

Public Function BatchSelectsql(ByVal sql As String,ByRef msg As String) As ADODB.Recordset Dim Conn As ADODB.Connection Dim rs As ADODB.Recordset Dim sTokens() As String On Error GoTo ErrorHandle sTokens = Split(sql) If InStr("SELECT",UCase((sTokens(0)))) Then If OpenConn(Conn) Then Set rs = New ADODB.Recordset rs.CursorLocation = adUseClIEnt rs.Open Trim$(sql),adLockBatchOptimistic Set Selectsql = rs msg = "²éѯµ½" & rs.RecordCount & " Ìõ¼Ç¼!" End If Else msg = "sqlÓï¾äÓÐÓï:" & sql End If ErrorHandle: msg = "²éѯ´íÎó£º" & Err.Description Err.Description Set rs = nothing Set Conn = noting Exit Function End Function

总结

以上是内存溢出为你收集整理的VB6.0全部内容,希望文章能够帮你解决VB6.0所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1286827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存