编码中的SQL查询问题 [英] Sql query problem in coding..
本文介绍了编码中的SQL查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
我在使用SQL Server进行C#编码时遇到问题.问题是,在sql中存在带有"int"数据类型的一列的表...当我尝试在该表中插入值时,就会出现错误. .
例如->
hello friends,
i have a problem in coding of C# with SQL server..problem is,there is table in sql with one column of ''int'' datatype...and when i try to insert values in that table then there comes an error..
eg->
int amt=Conevert.ToInt32(textbox1.text);
string sql="insert into Table values(amt)";
错误指向变量"amt" ...请帮助我...如何插入
the error is pointing at variable "amt"...plz help me...how to insert a
int
数字通过编码和变量....
number through coding and variable....
推荐答案
mySqlCommand.Parameters.AddWithValue("@amt", amt)
尝试以下操作:
string sql="insert into Table (amt) values(@amt)";
您为什么不这样做像
一样简单
Why don''t you do this just as simple as
int amt=Conevert.ToInt32(textbox1.text);
string sql="insert into Table values("+ amt +")";
这篇关于编码中的SQL查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文