帮我这个插入SQL查询... [英] help me with this Insert sql query...
本文介绍了帮我这个插入SQL查询...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cmd.CommandText = 插入 + table + values(' + textBox1.Text + ',' + textBox2.Text + ');;
i知道这是一个sipmle查询,但我还不知道为什么它显示错误...
cmd.CommandText =插入到+表(colA,colB)+ values('+ textBox1.Text +','+ textBox2.Text +');;
As另外,你应该看看c ommand参数 [ ^ ]。
这样的查询很危险 - SQL注入 [ ^ ]。
我猜这个问题表和值之间没有空格。在值之前给出一个空格。
cmd.CommandText = "insert into " + table + "values ('" + textBox1.Text + "', '" + textBox2.Text + "');";
i know this is a sipmle query, bt still i dont know why it is showing error...
解决方案
You have not defined the column names.
cmd.CommandText = "insert into " + table (colA, colB) + "values ('" + textBox1.Text + "', '" + textBox2.Text + "');";
As an aside, you should look at command parameters[^].
Queries like this are dangerous - SQL Injection[^].
I guess the problem is there is no space between table and values. Give a space before values.
这篇关于帮我这个插入SQL查询...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文