注册 登录
编程论坛 VB.NET论坛

求:VB2010中查询SQL2008数据库,查询并返回记录集的查询通用模块(代码)

lt_1970 发布于 2013-05-26 00:54, 2152 次点击
求:VB2010中查询SQL2008数据库,查询并返回记录集的查询通用模块(代码)

如下面的代码(VB6+SQL2000模式下),我是用VB6写的,如何修改成VB2010的(VB2010+SQL2008),哪位大侠有代码,发一个啊!十分感谢。

Public Function QueryExt(ByVal TmpSQLstmt As String) As ADODB.Recordset '--执行数据库查询语句
    Dim rst As New ADODB.Recordset
    set cnn = New ADODB.Connection
        With cnn
         .Provider = "sqloledb"
         .ConnectionString = Conn
         .ConnectionTimeout = 10
         .Open
        End With   
     Set rst.ActiveConnection = cnn
    rst.CursorType = adOpenKeyset
     rst.LockType = adLockOptimistic
    rst.Open TmpSQLstmt
    Set QueryExt = rst
End Function
0 回复
1