Dim cn_1 As ADODB.Connection
    Dim rs_1 As ADODB.Recordset
    Dim strSql_1 As String
        
On Error GoTo ErrHandle
        
        Set cn_1 = New ADODB.Connection
        Set rs_1 = New ADODB.Recordset
            cn_1.ConnectionString = "Provider=SQLOLEDB.1;" _
            + "Persist Security Info=false;Initial Catalog=BiologyMedicine;Data Source=yxygdb;user id=suhaihong;pwd=123456789" '广
        'cn_1.ConnectionTimeout = 30
        cn_1.Open
        
        'strSql = "select distinct Currentin.IceNO as  BioServer编号,Currentin.MedicineNo as 标签编号,Currentin.InTime as 入库时间,Currentin.CardNo as 卡号,OpHis.OpType as 操作类型,Goodsinfo.p_id as 厂商货号,OpHis.Supporter as 供应商编号 From Currentin, OpHis, Goodsinfo where Currentin.MedicineNo is not NULL and Currentin.IceNo='1000000000000001' and  Currentin.MedicineNo=OpHis.MedicineNo and Goodsinfo.p_id like OpHis.LabelNo+'%' and OpHis.OpType=1 order by Currentin.IceNO,Currentin.InTime,Goodsinfo.p_id"
        'strSql_1 = "select distinct Goodsinfo.p_id as 厂商货号,数量=sum(Goodsinfo.p_sl) From Currentin, OpHis, Goodsinfo where Currentin.MedicineNo is not NULL and Currentin.IceNo='" + Combo1.Text + "' and  Currentin.MedicineNo=OpHis.MedicineNo and Goodsinfo.p_id like OpHis.LabelNo+'%' and OpHis.OpType=1 group by Goodsinfo.p_id"
        
        strSql_1 = "select 厂商货号=replace(left(Currentin.MedicineNo,12),'&',''),数量=count(replace(left(Currentin.MedicineNo,12),'&','')) from Currentin where Currentin.MedicineNo is not null and Currentin.IceNo='" + Combo1.Text + "' group by replace(left(Currentin.MedicineNo,12),'&','')"
        
        rs_1.CursorLocation = adUseClient
        rs_1.CursorType = adOpenStatic
        rs_1.Open strSql_1, cn_1, adOpenKeyset, adLockPessimistic
        
        'Combo1.Text = rs_1.RecordCount
        Set DataGrid1.DataSource = rs_1
        
        'rs.Close
        'Set rs = Nothing
        'cn.Close
        'Set cn = Nothing
                
ErrHandle:
        MsgBox Err.Description
        Err.Clear谢谢!

解决方案 »

  1.   

    ErrHandle:
            MsgBox Err.Description
            Err.Clear
     是不是这个MSGBOX出现的对话框。改成MsgBox Err.Description & "AAAAAAAA"
     看看是不是有改变,如果有就是程序出错转到这里的,而Err.Description 的值是什么我就不知道了,因为我对error了解不多。
      

  2.   

    Set DataGrid1.DataSource = rs_1 后面没刷新,DataGrid是不会出现记录的
    应加上 DataGrid1.Refresh前面的就请楼主把错误说清楚一点!
      

  3.   

    直通到 ErrHandle:我犯过类似的错误, 让人感觉在用QB呀.
      

  4.   

    晕了,看楼主写代码很熟练的样子,怎么会犯这种低级错误?
    在 ErrHandle: 前面加个Exit Sub(Function).
      

  5.   

    On Error GoTo ErrHandle
    .................
    exit sub'这句很重要
    ErrHandle:
            MsgBox Err.Description
            Err.Clear