插入查询的40个值后给我一个语法错误....................有人帮助我为什么发生这个 [英] After 40 values of insert query give me a syntax error....................someone one help me why happend this

查看:70
本文介绍了插入查询的40个值后给我一个语法错误....................有人帮助我为什么发生这个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个解决方案一个给我同样的错误

请给我正确的消息



我尝试了什么:



这是我的代码,它处理40个值,但当我插入41和42文本框时,编译器给我异常:语法错误插入声明

i devlop一个工资单系统这个员工信息表格代码和Ms Access数据库链接

this Solution one give me the same error
please give me the right sugestion

What I have tried:

this is my code its working on 40 value but when i insert a 41 and 42 text box then the compiler give me the exception : "Syntax error Insert into statement"
i devlop a pay roll system this code of employee info form and Ms Access database link

推荐答案

不要这样做那个!

不要连接字符串来构建SQL命令。它让您对意外或故意的SQL注入攻击持开放态度,这可能会破坏您的整个数据库。改为使用参数化查询。



很可能,这将同时修复你的错误。

Don't do it like that!
Do not concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.

In all probability, that will fix your error at the same time.
using (OleDbConnection con = new OleDbConnection(strConnect))
    {
    con.Open();
    using (OleDbCommand cmd = new OleDbCommand("INSERT INTO myTable (myColumn1, myColumn2) VALUES (@C1, @C2)", con))
        {
        cmd.Parameters.AddWithValue("@C1", myValueForColumn1);
        cmd.Parameters.AddWithValue("@C2", myValueForColumn2);
        cmd.ExecuteNonQuery();
        }
    }


这篇关于插入查询的40个值后给我一个语法错误....................有人帮助我为什么发生这个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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