参数是在vb.net和sql中查询 [英] parameteris query in vb.net and sql
本文介绍了参数是在vb.net和sql中查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从不尝试使用参数化查询,请帮助将这种类型的查询用于插入,更新,删除执行.
i never try before using parameterise query pls help using this type of query for insert,update,delete perform
推荐答案
http://social.msdn.microsoft.com/Forums/pl-PL/vbgeneral/thread /6bdf8b71-1cf1-41c0-848c-4fca2c9e1ea2 [
http://social.msdn.microsoft.com/Forums/pl-PL/vbgeneral/thread/6bdf8b71-1cf1-41c0-848c-4fca2c9e1ea2[^]
Try it, do some more research and get back when you are stuck with any problem.
所有您需要做的就是
1.使用包含的参数名称声明您的命令
2.然后使用Parameters.AddWithValue
添加参数
像这样:
All you need to do is
1. Declare your Command with your parameter names included
2. Then add the Parameters using Parameters.AddWithValue
Like this:
SqlConnection conSql = new SqlConnection("Your Connection String Here");
SqlCommand cmd = new SqlCommand("SELECT ID, Name FROM MyTable WHERE ID = @ID",conSql);
cmd.Parameters.AddWithValue("@ID", requiredID);
希望这会有所帮助.
编辑抱歉,这是在c#中,但在VB中是相同的.编辑
Hope this helps.
EDIT Sorry, this is in c# but it''s the same in VB. EDIT
这篇关于参数是在vb.net和sql中查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文