在插入查询得到错误请找到它 [英] in insert query got error pls find it

查看:60
本文介绍了在插入查询得到错误请找到它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我这样做是为了插入数据



但我必须这样做

i have done this to insert data

but i have to do

insert into regtablename values('" + txtusername.Text + "','" + txtusersurname.Text + "','" + dldbirthdate.SelectedItem.Text + "','" + dldbirthmonth.SelectedItem.Text + "','" + dldbirthyear.SelectedItem.Text + "')";



i已经解决了,感谢您试图提供帮助我...



谢谢

Gaurang Raval


i have solve it thanks for trying to help me ...

thanks
Gaurang Raval

推荐答案

Pu这一行的调试点。运行代码。

一旦执行停止,将此行的值复制到管理工作室并执行查询。

查看错误,你可能能够弄清楚它的原因。
Put a debug point on this line. Run the code.
Once execution stops here, copy the value of this line into management studio and execute the query.
Looking at the error there, you may be able to figure out the cause of it.


试试

try as
string date= txtusersurname.Text +"/" +dldbirthdate.Text + "/" + dldbirthmonth.Text+ "/"+ dldbirthyear.Text;

 string str="insert into tablename values(@txtusername,@txtusersurname,@date)";
SqlCommand cmd=new SqlCommand(str,connection);
   cmd.Parameters.AddWithValue("txtusername",txtusername.Text);
   cmd.Parameters.AddWithValue("txtuserurname",txtuserurname.Text);
   cmd.Parameters.AddWithValue("date",date);


通过指定列名来尝试您的查询,例如, -



Try Your query by specifying the column name like,-

insert into tablename(COLUMN1,COLUMN2,...) VALUES(VALUE1,VALUE2,....)


这篇关于在插入查询得到错误请找到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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