VB高手帮我看一下这段VB程序吧

来源:百度知道 编辑:UC知道 时间:2024/05/26 08:01:03
帮我看一下这段VB程序吧.
悬赏分:10 - 离问题结束还有 14 天 19 小时
Private Sub cmdAdd_Click()
Dim RSAddNew As ADODB.Recordset
Set RSAddNew = MyConnection.Execute("Exec AccountTransactionsAdd '" _
& txtTransactionDate.Text & "','" & txtTransDescription.Text _
& "'," & cmbCategory.ItemData(cmbCategory.ListIndex) _
& "," & txtAmount.Text & ",'" _
& txtTransNote.Text & "'")
grdTrans.Row = grdTrans.Rows - 1
grdTrans.Col = 1
grdTrans.Text = RSAddNew("TheNewID")
grdTrans.Col = 2
grdTrans.Text = txtTransactionDate.Text
grdTrans.Col = 3
grdTrans.Text = txtTransDescription.Text
grdTrans.Col = 4
grdTrans.Text = cmbCategory.Text
grdTrans.Col = 5
grdTrans.Text = FormatCurrency(txtAmount.Text)
If CCur(txtAmount.Text) >= 0 Then
grdTrans.CellBackColor = &HC0FFC0
Else
grdTrans.CellBackColor = &HC0

sql语句有问题,建议你在调试的时候把("Exec AccountTransactionsAdd '" _
& txtTransactionDate.Text & "','" & txtTransDescription.Text _
& "'," & cmbCategory.ItemData(cmbCategory.ListIndex) _
& "," & txtAmount.Text & ",'" _
& txtTransNote.Text & "'")
的值看看对不对,在sql server中做一个测试。
因为这里只能看到你给的这个语句,对于你的AccountTransactionsAdd存储过程里边的参数无法知道类型,如果都是字符型的话,cmbCategory.ItemData(cmbCategory.ListIndex)就和其他的不一致,少了“‘’”。