如何在数据集查询插入中使用对象值 [英] How Use a Object value in Data set Query insert
本文介绍了如何在数据集查询插入中使用对象值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我想在数据集查询中使用对象值(TextBox)!
我的意思是,当我向数据集(FillBy ...)插入新查询时,我想使用文本框值
范例:
Hi
i would like Use a object value(TextBox) in DataSet Query !
my mean when i insert a new Query to Data set (FillBy...) i would like Use a Textbox Value
Example :
Select * From Login Where Username='"& Textbox1.text &"'
我无法在DataSet的查询生成器中使用文本框,该怎么办?!
谢谢您.
i cant Use Textbox in Query Builder of DataSet , How can i do it ?!
Thank you
推荐答案
作为经验法则,您不应使用诸如TextBox.Text
之类的数据来构成查询.相反,您应该创建一个或多个参数化查询,创建一个或多个数据库Command,然后通过传递数据中的参数来重新使用它.您没有告诉我们要使用哪个数据库提供程序;您没有告诉我们.而且我不想给您提供所有可能情况的示例,因为不同的数据库提供程序使用了不同的机制:它可以使用形式查询参数和对象之间的命名或位置对应.
请参见 http://msdn.microsoft.com/en-us/library/yy6y35y8.aspx [ ^ ].
—SA
As a rule of thumb, you should not compose your query out of the data such asTextBox.Text
. Instead, you should create one or more parametrized queries, create one or more database Command and re-use it by passing parameters from your data. You did not tell us what database provider you want to use; and I don''t want to give you examples of all possible cases, as different mechanisms are used for different database providers: it can use named or positional correspondence between formal query parameters and objects.
See http://msdn.microsoft.com/en-us/library/yy6y35y8.aspx[^].
—SA
这篇关于如何在数据集查询插入中使用对象值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文