以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  返回指定格式的string  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=93037)

--  作者:huhu
--  发布时间:2016/11/18 17:58:00
--  返回指定格式的string
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)
--  作者:有点青
--  发布时间:2016/11/18 18:09:00
--  
 和foxtable一样,你直接查询到表,然后循环每一行,合并成你想要的数据啊。
--  作者:huhu
--  发布时间:2016/11/18 18:31:00
--  
可明明有2行数据,却只返回第一行是怎么回事?
<?xml version="1.0" encoding="UTF-8"?>
<string xmlns="WebApplication4">生产订单号码:SC20160922001,工单行号:26,数量:15</string>

--  作者:有点蓝
--  发布时间:2016/11/19 8:39: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)
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)
        Dim dt As DataTable = cm.ExecuteReader
        cn.Close()
        Dim state As String
        For Each dr As DataRow In dt.datarow
            state + = \'工单号:\' + dr("工单号") + \',工单行号:\' + dr("工单行号") + ",物料编码:" + dr("物料编码") + ",数量:" + dr("数量")
        Next
        Return state
    End Function

图片点击可在新窗口打开查看此主题相关图片如下:error1.png
图片点击可在新窗口打开查看



--  作者:有点蓝
--  发布时间:2016/11/28 10:19:00
--  
vs的用法和foxtable不一样,找书或者上网先学学基本的用法

https://www.baidu.com/baidu?tn=02049043_69_pg&ie=utf-8&word=SqlDataAdapter

https://msdn.microsoft.com/zh-cn/library/system.data.sqlclient.sqldataadapter(VS.80).aspx

http://blog.sina.com.cn/s/blog_5c52ae1b0100q4uj.html

--  作者:huhu
--  发布时间:2016/11/28 10:24:00
--  
能先帮我改一下吗?
--  作者:有点蓝
--  发布时间:2016/11/28 10:39: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 adapter As New SqlClient.SqlDataAdapter("select * from [可用数量表]  where 订单号 = \'" & ddh & "\' and 订单行号 = \'" & ddhh & "\' and 物料编码 = \'" & wlbm & "\' and 两化表编号 = \'" & lhbbh & "\' and 软件版本 = \'" & rjbb & "\'", cn)

        Dim dt As New DataTable
        adapter.Fill(dt)
        cn.Close()
        Dim state As String = ""
        For Each dr As DataRow In dt.Rows
            state += "工单号:" + dr("工单号") + ",工单行号:" + dr("工单行号") + ",物料编码:" + dr("物料编码") + ",数量:" + dr("数量")
        Next
        Return state
    End Function

--  作者:huhu
--  发布时间:2016/11/28 11:22:00
--  

输入参数后提示下面的:

网站无法显示该页面

 HTTP 500
 

最可能的原因是:

  • 该网站正在进行维护。
  • 该网站有程序错误。
 

你可以尝试以下操作:

 

图片点击可在新窗口打开查看 刷新该页面。

 

图片点击可在新窗口打开查看 返回到上一页。

 

图片点击可在新窗口打开查看 详细信息

另外多行要分行显示出来。用vbcrif?
state += "工单号:" + dr("工单号") + ",工单行号:" + dr("工单行号") + ",物料编码:" + dr("物料编码") + ",数量:" + dr("数量")