普通网友 2017-12-28 07:08 采纳率: 100%
浏览 1499
已采纳

急急急!SQLserver通过adodb连接问题,大神进

With Adodc1.Recordset
If .RecordCount > 0 Then
Do While .EOF = False
View_tfdata
.MoveNext
Loop
End If
End With
如何把此段代码改成用ADODB

  • 写回答

4条回答 默认 最新

  • 普通网友 2018-01-14 11:22
    关注

    Dim cn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim sql1 As String
    Dim sql2 As String
    cn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MZJJSFXT;Data Source=."
    cn.Open
    sql1 = "select 结算方式 as 收款方式,count(收据号)as 收据数,sum(总金额)as 金额 from 收费单据信息表 where 操作员='" + Txtsky.Text + "'and 收据号 between '" + Txtsjn1.Text + "'And '" + Txtsjn2.Text + "'group by 结算方式"
    If rs.State = adStateOpen Then rs.Close
    rs.CursorLocation = adUseClient
    rs.Open sql1, cn, adOpenKeyset, adLockOptimistic
    With rs
    If rs.RecordCount > 0 Then
    Do While rs.EOF = False
    View_sfdata
    rs.MoveNext
    Loop
    End If
    End With
    rs.Close
    Set rs = Nothing

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 学校优化算法sbo和蚁群算法怎么结合
  • ¥20 Apache poi使用问题
  • ¥21 matlab怎么求时域信号的二阶导数
  • ¥15 判断两个表是否完全相同
  • ¥15 java map类型数据格式,如何快速通过前缀匹配元素
  • ¥15 stc12c5a60s2、QMC5883L、LCD1602组合测量磁场所需程序
  • ¥20 Win11测试yolov4,“找不到nvcuda.dll”怎么办?
  • ¥15 simulink绘制bode图
  • ¥15 php_network_getaddresses: getaddrinfo failed: Name or service not known
  • ¥15 用msg发消息出现的问题