方法1、。SQL改为这种:se1ect top 100 * fr0m ITEM where item_code like '【_code_no】%' order by item_code 然后查询执行参考:
dim _no_id as string= "1"
dim dr as datarow = datatables("sql_sent").find("NO_ID=" & _no_id)
if dr isnot nothing then
dim _code_no as string = "xxx"
Dim cmd As New SQLCommand
cmd.ConnectionName = "数据源名称"
Dim dt As DataTable
cmd.CommandText = dr("sent_A").replace("【_code_no】",_code_no)
dt = cmd.ExecuteReader()
end if
方法2,SQL改为这种:se1ect top 100 * fr0m ITEM where item_code like ? order by item_code
然后查询执行参考:
dim _no_id as string= "1"
dim dr as datarow = datatables("sql_sent").find("NO_ID=" & _no_id)
if dr isnot nothing then
dim _code_no as string = "xxx" & "%"
Dim cmd As new SQLCommand
cmd.ConnectionName = "数据源名称"
cmd.CommandText = dr("sent_A")
cmd.Parameters.Add("@code_no",_code_no)
Dim dt As DataTable = cmd.ExecuteReader()
end if