Visual Basic 6插入sql [英] Visual Basic 6 Insert sql

查看:64
本文介绍了Visual Basic 6插入sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我有这个代码:



Hi

I have this code:

If Len(txtSalary.Text) = 0 Or Len(txtmCover.Text) = 0 Or Len(txtMember.Text) = 0 Or Len(txtmRate.Text) = 0 Then

       MsgBox "Enter Values"

    Else
        tsql = "INSERT INTO Hpacc4(SalaryBill,Rate,Membership,Cover) " & _
               "VALUES('" & txtSalary.Text & "','" & txtmCover & "', '" & txtMember.Text & "', '" & txtmRate.Text & "')" & _
               "WHERE Scheme = '99993' AND RunMonth = '200604' AND AccCode = '110'"

       cnHPtest.Execute (tsql)

      
    End If





当我运行它时,我的WHERE caluse会出错,请帮忙。我无法看到我在哪里出错。



When I run it I get an error at my WHERE caluse, please help. I can't see where I went wrong there.

推荐答案

你不能在这样的Insert语句中使用WHERE子句。你需要重新思考你想要完​​成和重写的内容。也许您需要完全删除WHERE,或者您也可以将这些值插入表中。
You can't use a WHERE clause in an Insert statement like this. You need to rethink what you are trying to accomplish and re-write. Perhaps you need to remove the WHERE altogether or perhaps you mean to insert those values into the table as well.


1 - 您的插入语句的顺序不正确(薪水,费率,成员资格) ,封面)

作为你的文本框。

2 - 插入时没有'哪里'。

3 - 你可能想要的改为做更新:



更新Hpacc4

设置SalaryBill = txtSalary.Text,

Rate = txtmCover .Text,

Membership = txtMember.Text,

封面= txtmCover.text

WHERE Scheme ='99993'AND RunMonth ='200604' AND AccCode ='110'



(请确保在代码中使用适当的引号,上述声明
1-Your insert statement is not in the right order (Salary, Rate, Membership, Cover)
as your text boxes.
2-There is no 'Where' when doing an Insert.
3-you probably want to do an Update instead :

Update Hpacc4
Set SalaryBill = txtSalary.Text,
Rate = txtmCover.Text,
Membership=txtMember.Text,
Cover = txtmCover.text
WHERE Scheme = '99993' AND RunMonth = '200604' AND AccCode = '110'

(make sure you use the appropriate quotes in code, the above statement


这篇关于Visual Basic 6插入sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆