以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  这段代码我只想product表里添加一条记录 结果是添加了两个  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=67869)

--  作者:jinzhengbe
--  发布时间:2015/5/5 13:59:00
--  这段代码我只想product表里添加一条记录 结果是添加了两个

这段代码我只想product表里添加一条记录 结果是添加了两个 ? 请问该怎么修改

 

 

If e.DataRow.isnull("cord")=False Then
       Dim dr As DataRow
        dr = DataTables("product").Find("[cord] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
            e.DataRow("name") = dr("shangpinming")
            e.DataRow("markprice") = dr("markprice")
           
Else

e.DataRow("nnn")=e.DataRow("name")     

If e.DataRow.isnull("nnn")=False And dr Is Nothing Then
Dim idxs As String = ""
For i As Integer = Tables("rukudanhao.rukudan").TopPosition To Tables("rukudanhao.rukudan").BottomPosition
    idxs &= Tables("rukudanhao.rukudan").Rows(i)("_Identify")
Next

Dim f As New Filler
f.Filter = "_Identify in (" & idxs.Trim(",") & ")"
f.SourceTable = DataTables("rukudan") \'指定数据来源
f.SourceCols = "cord,name,markprice" \'指定数据来源列
f.DataTable = DataTables("product") \'指定数据接收表
f.DataCols = "cord,shangpinming,markprice" \'指定数据接收列
f.Fill() \'填充数据
DataTables("product").save()
End If
End If


end If

[此贴子已经被作者于2015/5/5 14:00:45编辑过]

--  作者:Bin
--  发布时间:2015/5/5 14:00:00
--  
代码发出来
--  作者:jinzhengbe
--  发布时间:2015/5/5 14:02:00
--  

If e.DataRow.isnull("cord")=False Then
       Dim dr As DataRow
        dr = DataTables("product").Find("[cord] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
            e.DataRow("name") = dr("shangpinming")
            e.DataRow("markprice") = dr("markprice")
           
Else

e.DataRow("nnn")=e.DataRow("name")     

If e.DataRow.isnull("nnn")=False And dr Is Nothing Then
Dim idxs As String = ""
For i As Integer = Tables("rukudanhao.rukudan").TopPosition To Tables("rukudanhao.rukudan").BottomPosition
    idxs &= Tables("rukudanhao.rukudan").Rows(i)("_Identify")
Next

Dim f As New Filler
f.Filter = "_Identify in (" & idxs.Trim(",") & ")"
f.SourceTable = DataTables("rukudan") \'指定数据来源
f.SourceCols = "cord,name,markprice" \'指定数据来源列
f.DataTable = DataTables("product") \'指定数据接收表
f.DataCols = "cord,shangpinming,markprice" \'指定数据接收列
f.Fill() \'填充数据
DataTables("product").save()
End If
End If


end If


--  作者:Bin
--  发布时间:2015/5/5 14:06:00
--  
你没有判断列名. 好像之前都提醒过你好几次.

DataColChanged 等事件一定要加入列名判断.

你改变哪个列才触发这个事件一定要判断好.否则你更改列其他列的值,就会一直触发多次.  

--  作者:狐狸爸爸
--  发布时间:2015/5/5 14:07:00
--  
楼主回头看帮助,看不下去就先看置顶的视频教程,你这样开发出来的系统会有各种的漏洞。
--  作者:jinzhengbe
--  发布时间:2015/5/5 14:22:00
--  

加了,

一样

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:丽颜.foxdb

[此贴子已经被作者于2015/5/5 14:24:05编辑过]

--  作者:Bin
--  发布时间:2015/5/5 14:23:00
--  

if e.datacol.name = "cord" then

If e.DataRow.isnull("cord")=False Then
       Dim dr As DataRow
        dr = DataTables("product").Find("[cord] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing
            e.DataRow("name") = dr("shangpinming")
            e.DataRow("markprice") = dr("markprice") 
            
Else

e.DataRow("nnn")=e.DataRow("name")     

If e.DataRow.isnull("nnn")=False And dr Is Nothing Then
Dim idxs As String = ""
For i As Integer = Tables("rukudanhao.rukudan").TopPosition To Tables("rukudanhao.rukudan").BottomPosition
    idxs &= Tables("rukudanhao.rukudan").Rows(i)("_Identify")
Next

Dim f As New Filler
f.Filter = "_Identify in (" & idxs.Trim(",") & ")"
f.SourceTable = DataTables("rukudan") \'指定数据来源
f.SourceCols = "cord,name,markprice" \'指定数据来源列
f.DataTable = DataTables("product") \'指定数据接收表
f.DataCols = "cord,shangpinming,markprice" \'指定数据接收列
f.Fill() \'填充数据
DataTables("product").save()
End If
End If

end if
end If


--  作者:jinzhengbe
--  发布时间:2015/5/5 14:31:00
--  

不对啊

数据反尔  添加了


--  作者:Bin
--  发布时间:2015/5/5 14:35:00
--  
数据反而添加了?
--  作者:大红袍01
--  发布时间:2015/5/5 15:46:00
--  
 你这段代码到底想做什么啊?直接说,做什么操作以后,达到什么效果