VB中同时定义多个数据控件怎么做啊
我想同时使用两个数据控件,写完运行报“实时错误,要求对象”PrivateSubCommand1_Click()Dimconn1AsNewADODB.ConnectionD...
我想同时使用两个数据控件,写完运行报“实时错误,要求对象”
Private Sub Command1_Click()
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim cnn2 As New ADODB.Connection
Dim rs2 As New ADODB.Connection
'Set conn = CreateObject("ADODB.Connection")
mdbfile = "D:\Software\ast541g\ast541g\ASTRO3.mdb"
conn1.Open "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=SAIC_Chery"
conn2.Open "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=SAIC_Chery"
rs1.Open "select * from P_ALARMS ", conn, adOpenKeyset, adLockReadOnly
rs2.Open "select * from P_counters ", conn, adOpenKeyset, adLockReadOnly
rs2.Close
conn2.Close
Set conn2 = Nothing
rs1.Close
conn1.Close
Set conn1 = Nothing
End Sub
在这句报的,有没高手看看是咋回事啊?
conn2.Open "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=SAIC_Chery" 展开
Private Sub Command1_Click()
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim cnn2 As New ADODB.Connection
Dim rs2 As New ADODB.Connection
'Set conn = CreateObject("ADODB.Connection")
mdbfile = "D:\Software\ast541g\ast541g\ASTRO3.mdb"
conn1.Open "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=SAIC_Chery"
conn2.Open "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=SAIC_Chery"
rs1.Open "select * from P_ALARMS ", conn, adOpenKeyset, adLockReadOnly
rs2.Open "select * from P_counters ", conn, adOpenKeyset, adLockReadOnly
rs2.Close
conn2.Close
Set conn2 = Nothing
rs1.Close
conn1.Close
Set conn1 = Nothing
End Sub
在这句报的,有没高手看看是咋回事啊?
conn2.Open "driver={SQL Server};" & "server=user-PC;uid=sa;pwd=lenovo;database=SAIC_Chery" 展开
2个回答
2011-03-24
展开全部
Dim conn1 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim cnn2 As New ADODB.Connection '''''喂喂,你定义的是cnn2,然后你用的是conn2,不出错才怪。
Dim rs2 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Dim cnn2 As New ADODB.Connection '''''喂喂,你定义的是cnn2,然后你用的是conn2,不出错才怪。
Dim rs2 As New ADODB.Connection
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询