我在我的表Table1
中有两列syntax
和query
。语法包含名为po
的数据和名为select * from po_pomas_pur_order_hdr where pomas_pono =
的查询。我用在查询中动态传递一个值?
SqlDataAdapter da = new SqlDataAdapter("select query from Table1 where syntax = '" + textBox1.Text + "'", conn);
得到这个查询值与我的问题是,我需要动态传递,我使用的DataAdapter这样retrived查询内的另一个值:
SqlDataAdapter da1 = new SqlDataAdapter(da.tostring() +"'"+ textBox1.Text +"'", conn)
生成的查询应该是这样的这个:
select * from po_pomas_pur_order_hdr where pomas_pono = '2PO/000002/09-10'
但是这是不可能的。如何获得这样的查询?任何建议?
我可以”不明白你到底想要什么? – 2011-06-14 07:14:16
第一件事将是使用[参数](http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx)而不是直接从(可能是恶意)用户的文本。 – 2011-06-14 07:17:41
从我的理解你想创建一个复杂的SQL查询,会给你一个查询结果? – ub1k 2011-06-14 07:17:50