问题描述
我在sql中有一个数据表MapImageData,它包含
Id(Int)
source(varchar(max))
目的地(varchar(max))
User_comment(varchar(max))
我也有gui ..其中持有源,目的地和用户评论文本框
所以问题是
i希望用sql数据库源和目的地检查用户输入源和目的地.. 。
如果正确
i也想添加用户评论
i have a datatable MapImageData in sql which holds
Id(Int)
source(varchar(max))
destination(varchar(max))
User_comment(varchar(max))
also i have gui.. which holds source, destination and usercomment textboxes
so the problem is
i want to check userinput source and destination with sql database source and destination...
and if its correct
i want to add user comment also
String QueryStr = "INSERT INTO MapImageData(User_Comment) VALUES (@User_Comments)" WHERE Source='" + Source_Box.Text + "' AND Destination='" + Distance_Box.Text + "'";
SqlCommand scmd1 = new SqlCommand(QueryStr, conn2);
scmd1.Parameters.AddWithValue("@User_Comments", UserComment.Text);
但有人说我不能使用带插入条件的地方..
所以如何解决他的问题.........
but someone said i can't use where condition with insert..
so how can i solve his problem.........
推荐答案
这篇关于使用检查值插入查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!