问题描述
我有一段代码,可读取Sql查询的xml文件.代码工作正常,但没有返回行..i我在Access数据库上尝试了相同的查询,但返回行
HTML
----
< Test>
< TR_PARAM>材料问题</TR_PARAM>
< TR_QUERY>从物料所在的位置(发布日期& gt; @ P1<<> @ ;/TR_QUERY>
< TR_FREEZ> N</TR_FREEZ>
< TR_PARAM1> 7:7</TR_PARAM1>
< TR_NO_PARAM> 3</TR_NO_PARAM>
< TR_DEF_UPLOAD> Y</TR_DEF_UPLOAD>
< TR_TYP_2> 0</TR_TYP_2>
< TR_TYP_3> FD:TDT</TR_TYP_3>
< TR_TYP_4> 100</TR_TYP_4>
</Test>
VB.net代码
-------------
tblname = dro("tr_param")
昏暗的cmd作为新的OleDbCommand(dro("tr_query"),cnn)
Dim arrctl()As String = Split(dro("TR_TYP_3"),:")
Dim arrpr()As String = Split(dro("tr_param1"),:")
For i As Byte = 0 To dro("TR_NO_PARAM")-1
如果i = 2那么
将Dim P3作为新的OleDbParameter("@ P3",Locname)
P3.Value = Locname
cmd.Parameters.Add(P3)
其他
将Dim p设置为新的OleDbParameter("@ P"& i + 1,arrpr(i))
p.Value = IIf(arrctl(i)="FD",dtpfrom.Text,IIf(arrctl(i)="TDT",dtpTo.Text,"))
cmd.Parameters.Add(p)
如果结束
下一个
将Dim dts作为新的DataTable(dro("tr_param"))
dts.Load(cmd.ExecuteReader)
"请注意,从另一个文本文件中读取P3的值为"DBMALU"
I have a Section of Code that read an xml file for an Sql Query. the code work fine but no rows returned..i tried the same query on Access database it return rows
HTML
----
<Test>
<TR_PARAM>MATERIALISSUE</TR_PARAM>
<TR_QUERY>SELECT SERIALNO,ISSUEDATE,SALESORDERCODE,INVITEMCODE,QTY,UNITCODE,POSITEMCODE,ITEMTYPE,SERVINGUNITCODE,SERVINGQTY,REFSERIALNO ,@P3 FROM MATERIALISSUE WHERE (ISSUEDATE >@P1 AND ISSUEDATE <@P2)</TR_QUERY>
<TR_FREEZ>N</TR_FREEZ>
<TR_PARAM1>7:7</TR_PARAM1>
<TR_NO_PARAM>3</TR_NO_PARAM>
<TR_DEF_UPLOAD>Y</TR_DEF_UPLOAD>
<TR_TYP_2>0</TR_TYP_2>
<TR_TYP_3>FD:TDT</TR_TYP_3>
<TR_TYP_4>100</TR_TYP_4>
</Test>
VB.net Code
-------------
tblname = dro("tr_param")
Dim cmd As New OleDbCommand(dro("tr_query"), cnn)
Dim arrctl() As String = Split(dro("TR_TYP_3"), ":")
Dim arrpr() As String = Split(dro("tr_param1"), ":")
For i As Byte = 0 To dro("TR_NO_PARAM") - 1
If i = 2 Then
Dim P3 As New OleDbParameter("@P3", Locname)
P3.Value = Locname
cmd.Parameters.Add(P3)
Else
Dim p As New OleDbParameter("@P" & i + 1, arrpr(i))
p.Value = IIf(arrctl(i) = "FD", dtpfrom.Text, IIf(arrctl(i) = "TDT", dtpTo.Text, ""))
cmd.Parameters.Add(p)
End If
Next
Dim dts As New DataTable(dro("tr_param"))
dts.Load(cmd.ExecuteReader)
''Note take Value of P3 as "DBMALU" read from another text file
推荐答案
这篇关于ExecuteReader不返回任何内容紧急帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!