多列更新的更新查询语法 [英] syntax of update query for multiple column update

查看:108
本文介绍了多列更新的更新查询语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不更新一个表,我尝试了两个查询,但是它显示语法错误,有人可以帮助我吗,我知道这是基本的,但是我是一个初学者.


 字符串查询= "  + txtName.Text +  ',并设置密码='" + txtpassword.Text + "  + txtphoneno.Text + "  + rtxtAdress.Text +  '其中,userid ='" + txtuserid.Text +  '";




字符串查询= "  + txtName.Text + "  + txtpassword.Text + "  + txtphoneno.Text + " ',adress ='" + rtxtAdress.Text +   + txtuserid.Text + " ;



由于update语句中的语法错误,它显示oledbexception,不是用户ID是文本,而是唯一的NON DUPLICABLE
我还有很多要更新的大表的任何其他想法是否可以使用任何其他想法进行更新?正在关注

 字符串查询= "  + txtName.Text +  ',密码='" + txtpassword.Text + "  + txtphoneno.Text + "  + rtxtAdress.Text + " ',其中userid =" + txtuserid.Text; 


I had to update a table i tried two queries but it shows syntax error can anyone help me pls I know this is basic but i am a begginer


String query = "Update masterusertable set username='" + txtName.Text + "',and set password='" + txtpassword.Text + "',and set phoneno='" + txtphoneno.Text + "',and set adress='" + rtxtAdress.Text + "' where userid ='" + txtuserid.Text + "'";




String query = "Update masterusertable set username='" + txtName.Text + "', password='" + txtpassword.Text + "', phoneno='" + txtphoneno.Text + "', adress='" + rtxtAdress.Text + "' where userid ='" + txtuserid.Text + "'";



its shows oledbexception due to syntax error in update statement ,no the userid is text but unique NON DUPLICABLE
anyother idea i had many big tables to be updated is it good to update using anyother ideas

解决方案

Your second query looks good, but if userid is a numeric field, use following

String query = "Update masterusertable set username='" + txtName.Text + "', password='" + txtpassword.Text + "', phoneno='" + txtphoneno.Text + "', adress='" + rtxtAdress.Text + "' where userid =" + txtuserid.Text;


这篇关于多列更新的更新查询语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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