尼莫和可爱多
2017-12-28 07:08
采纳率: 100%
浏览 1.5k

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

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

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • lucky_nice 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条)

相关推荐 更多相似问题