Public Function GetState1(ByVal ddh As String, ByVal ddhh As String, ByVal wlbm As String, ByVal lhbbh As String, ByVal rjbb As String) As String
Dim cnStr As String = "Data Source=(local);Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
Dim cn As New SqlClient.SqlConnection(cnStr)
cn.Open()
Dim cm As New SqlClient.SqlCommand("s elect 数量 from [可用数量表] where 订单号 = \'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 物料编码 = \'" & wlbm & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)
Dim state As String = cm.ExecuteScalar
cn.Close()
Return state
End Function
现在返回的就是一个数量值。
假如有A,B,C,数量4个列他们只为1,2,3,4
希望返回的格式为A:1,B:2,C:3,D:4
这种格式怎么弄?
-- 作者:有点蓝
-- 发布时间:2016/11/18 18:06:00
-- Dim cm As New SqlClient.SqlCommand("s elect \'A:\'+ cast([A] as nvarchar) + \',B:\'+ cast([B] as nvarchar) + ...... from [可用数量表] where 订单号 = \'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 物料编码 = \'" & wlbm & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)
Public Function GetState1(ByVal ddh As String, ByVal ddhh As String, ByVal wlbm As String, ByVal lhbbh As String, ByVal rjbb As String) As String
Dim cnStr As String = "Data Source=(local);Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
Dim cn As New SqlClient.SqlConnection(cnStr)
cn.Open()
Dim cm As New SqlClient.SqlCommand("s elect * from [可用数量表] where 订单号 = \'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 物料编码 = \'" & wlbm & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)
Dim dt As DataTable = cm.ExecuteReader
cn.Close()
Dim state As String
For Each dr As DataRow In dr.DataRow
\'拼接每行的数据
Next
Return state
End Function
-- 作者:huhu
-- 发布时间:2016/11/28 10:07:00
--
Public Function GetState1(ByVal ddh As String, ByVal ddhh As String, ByVal wlbm As String, ByVal lhbbh As String, ByVal rjbb As String) As String
Dim cnStr As String = "Data Source=(local);Initial Catalog=songjiang;Integrated Security=False;User ID=sa;Password=bdcom103liujy;"
Dim cn As New SqlClient.SqlConnection(cnStr)
cn.Open()
Dim cm As New SqlClient.SqlCommand("s elect * from [可用数量表] where 订单号 = \'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 物料编码 = \'" & wlbm & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)