求:VB2010中查询SQL2008数据库,查询并返回记录集的查询通用模块(代码)
求: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