主题:[讨论]万分火急!请各位帮忙!!!怎样解决VB和SQL2000数据库的问题!!!
使用VB和SQL2000数据库
Sub Main()
frmykgl.Show
End Sub
Public Function cnn() As ADODB.Connection '定义函数
Set cnn = New ADODB.Connection
'返回一个数据库连接
cnn.Open "Driver={SQL Server};Server=NTSERVER;Database=his66;Uid=sa;Pwd=22"
End Function
Public Function cnStr() As String
cnStr = "Provider=SQLOLEDB.1;pwd=22;Persist Security Info=False;User ID=sa;Initial Catalog=his666;Data Source=NTSERVER"
End Function
Private Sub Search()
Set cmd = New ADODB.Command
Dim cnn As New Connection
Dim cmdChange As New Command
Dim rsChange As New Recordset
cnn.Open cnStr
cmdChange.ActiveConnection = cnn
cmdChange.CommandType = adCmdStoredProc
cmdChange.CommandText = "yk_pzgl" 'yk_pzgl存贮过程名称
Set rsChange = cmdChange.Execute()
Set DataGrid2.DataSource = rsChange
End Sub
错误提示:实时错误‘7004’,行集合不能做为标签
我想要用这样的方式调用存贮过程,用DataGrid2控件来显示数据,怎样来解救这个问题,希望高手多多指教!!
Sub Main()
frmykgl.Show
End Sub
Public Function cnn() As ADODB.Connection '定义函数
Set cnn = New ADODB.Connection
'返回一个数据库连接
cnn.Open "Driver={SQL Server};Server=NTSERVER;Database=his66;Uid=sa;Pwd=22"
End Function
Public Function cnStr() As String
cnStr = "Provider=SQLOLEDB.1;pwd=22;Persist Security Info=False;User ID=sa;Initial Catalog=his666;Data Source=NTSERVER"
End Function
Private Sub Search()
Set cmd = New ADODB.Command
Dim cnn As New Connection
Dim cmdChange As New Command
Dim rsChange As New Recordset
cnn.Open cnStr
cmdChange.ActiveConnection = cnn
cmdChange.CommandType = adCmdStoredProc
cmdChange.CommandText = "yk_pzgl" 'yk_pzgl存贮过程名称
Set rsChange = cmdChange.Execute()
Set DataGrid2.DataSource = rsChange
End Sub
错误提示:实时错误‘7004’,行集合不能做为标签
我想要用这样的方式调用存贮过程,用DataGrid2控件来显示数据,怎样来解救这个问题,希望高手多多指教!!