以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  HttpRequest 未将对象引用设置到对象的实例 ,麻烦老师看看。  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=133462)

--  作者:李孝春
--  发布时间:2019/4/15 10:14:00
--  HttpRequest 未将对象引用设置到对象的实例 ,麻烦老师看看。
.NET Framework 版本:2.0.50727.8940
Foxtable 版本:2018.10.9.1
错误所在事件:项目,HttpRequest
详细错误信息:
未将对象引用设置到对象的实例。


    Case "addnewtxl.htm"
        If e.PostValues.Count = 0 Then
            wb.AddForm("","form1","addnewtxl.htm")
            With wb.AddInputGroup("form1","ipg1","干警信息")               
                Dim filter11 As String = "表名 = \'干警信息\' and 列名 = \'所在单位\' and 停用 = false"
                Dim fdr11 As DataRow = DataTables("列项设置").Find(filter11)
                If fdr11 IsNot Nothing Then
                    Dim abc11 As String=fdr11("下拉选项").replace(",", "|")
                    .AddSelect("所在单位","所在单位","|"&abc11)
                End If              
                .AddInput("姓名","姓名","Text") \'前一个"姓名"是ID,后一个"姓名"是标题
                .AddInput("电话","电话","number")
                .AddInput("电子邮件","电子邮件","text")
                .AddInput("QQ号","QQ号","text")
                .AddInput("微信号","微信号","text") 
                Dim filter As String = "表名 = \'干警信息\' and 列名 = \'身份属性\' and 停用 = false"
                Dim fdr As DataRow = DataTables("列项设置").Find(filter)
                If fdr IsNot Nothing Then
                    Dim abc As String=fdr("下拉选项").replace(",", "|")
                    .AddSelect("身份属性","身份属性","|"&abc)
                End If  
                Dim filter1 As String = "表名 = \'干警信息\' and 列名 = \'关注领域\' and 停用 = false"
                Dim fdr1 As DataRow = DataTables("列项设置").Find(filter1)
                If fdr1 IsNot Nothing Then
                    Dim abc1 As String=fdr1("下拉选项").replace(",", "|")
                    .AddSelect("关注领域","关注领域","|"&abc1)
                End If  
            End With
            With wb.AddButtonGroup("form1","btg1",True)
                .Add("btn1", "确定", "submit")
                .Add("btn2","取消","reset")
            End With
            
            With wb.AddTable("","Table1")
                .RowHead = 1
                .ColWidth = "12px"
                Dim nms() As String = {"姓名","电话","电子邮件","身份属性","所在单位"}
                .Head.AddRow(nms)
                Dim cnt As Integer
                For Each r As DataRow In DataTables("干警信息").Select("姓名 <>\'\'")
                    cnt = cnt + 1
                    With .Body.AddRow(r("姓名"),r("电话"),r("电子邮件"),r("身份属性"),r("所在单位"))
                        \'.AddCell(Format(r("单价"),"#0.00"))
                        \'.AddCell(Format(r("日期"),"MM月dd日"))
                    End With
                Next
            End With
            e.WriteString(wb.Build)
        Else
            Dim nms() As String = {"姓名","电话"} \'不能为空的列名数组
            For Each nm As String In nms
                If e.PostValues.ContainsKey(nm) = False Then \'生成错误提示页
                    With wb.AddMsgPage("","msgpage","增加失败", nm & "列不能为空!")
                        .icon = "Warn" \'改变图标
                        .AddButton("btn1","返回").Attribute = ""
                    End With
                    e.WriteString(wb.Build)
                    Return \'必须返回
                End If
            Next
            nms = New String() {"姓名","电话","电子邮件","身份属性","所在单位","关注领域","微信号","QQ号"}  \'重新定义了nms数组,增加了两列.
            Dim dr As DataRow = DataTables("干警信息").AddNew()
            For Each nm As String In nms
                If e.PostValues.ContainsKey(nm) Then
                    dr(nm) = e.PostValues(nm)                    
                End If
            Next
            If dr("所在单位") <>"" Then
                Dim dr11 As DataRow
                dr11 = DataTables("行政区域").Find("所在单位 = \'"&dr("所在单位")&"\' ")
                dr("所在省份")=dr11("所在省份")
                dr("所在地区")=dr11("所在地区")
                dr("所在县份")=dr11("所在县市")
            End If
            With wb.AddMsgPage("","msgpage","增加成功", "好好学习,天天向上") \'生成成功提示页
                .AddButton("btn1","继续增加","addnewtxl.htm")
            End With           
            e.WriteString(wb.Build)
        End If

--  作者:有点甜
--  发布时间:2019/4/15 10:19:00
--  

这段代码,对dr11进行判断才行,如

 

                Dim dr11 As DataRow
                dr11 = DataTables("行政区域").Find("所在单位 = \'"&dr("所在单位")&"\' ")
msgbox(dr("所在单位"))
If dr11 IsNot Nothing Then
                dr("所在省份")=dr11("所在省份")
                dr("所在地区")=dr11("所在地区")
                dr("所在县份")=dr11("所在县市")
End If