以下是引用tianxiaoyu在2005-9-22 17:59:31的发言:Option Explicit Public db As ADODB.Connection Public rs As ADODB.Recordset Public Sub connect() Set db = New ADODB.Connection db.Open "provider=mssqlserver;data source=cl,uid=sa;pwd=,database=lg" Set rs = New ADODB.Recordset End Sub Private Sub CommandButton1_Click()
Dim i As Integer, j As Integer, h As Integer, sql As String, rg As Range sql = "select count(*) from scrb where nf='" & ComboBox1.Text & "' and yf='" & ComboBox2.Text & "' and rf='" & ComboBox3.Text & "'" rs.Open sql, db i = rs.Fields(0) rs.Close 请求斑竹帮忙,为什么运行的时候rs.Open sql, db有错,db=nothing 那?? 谢谢帮忙
db's connectstring is error try cnnstr="provider=sqloledb;data source=cl;user id=sa;password=';initial catalog=lg'" db.open cnnstr |