vb+sql,vb设计用户界面,用VB(dll)能否直接建立数据库?如何连接?能连接如何进行调试?谢谢~~

来源:百度知道 编辑:UC知道 时间:2024/05/23 19:49:01
你做了,我也不知道啊,能否从基础说啊,谢谢o(∩_∩)o...

ublic Function ConnectDB(Optional ByVal intConnectTimeOut As Integer, Optional intCommandTimeOut As Integer) As ADODB.Connection
Dim SourceConn As New ADODB.Connection
Dim strConnectString As String
strConnectString = "Provider=MSDASQL.1;Extended Properties=DRIVER=SQL Server;SERVER=192.168.100.11;UID=sa;PWD=*****" SourceConn.ConnectionTimeout = 500
SourceConn.CommandTimeout = 500
SourceConn.Open strConnectString
Set ConnectDB = SourceConn
Set SourceConn = Nothing
End Function
Public Function GetRsBySql(ByVal strSql As String) As ADODB.Recordset
On Error GoTo errHandle
Dim rs As New ADODB.Recordset
Dim conn As New ADODB.Connection
Set conn = ConnectDB()
rs.CursorLocation = adUseClient
rs.LockType = adLockOptimistic
rs.Open strSql, conn
Set GetRsBySql = rs
' GetRsBySql.CacheSize = 1000
Set rs = Nothing