以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  表达式错误  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=56333)

--  作者:riyuan
--  发布时间:2014/9/3 12:19:00
--  表达式错误
Dim d As Date = Date.Today
Dim cmd As new SQLCommand
cmd.C
If Tables("pl_Table1").Filter > "" Then
Dim Val As Integer 

If InputValue(Val, "缴费金额", "请输入缴费金额:") Then
For Each r As Row In Tables("pl_table1").Rows
    
    cmd.CommandText = "Insert into {xlh} (户号,姓名,身份证号,合作医疗证号,参合时间,缴费金额) Select{hkxx}.户号,姓名,身份证号,{ylz}.医疗证号,\'" & d & "\',\'" & val & "\' from {hkxx} INNER JOIN {ylz} ON {hkxx}.户号 = {ylz}.户号  where r.Checked=true  " & Tables("pl_Table1").Filter.replace("户号","{hkxx}.户号")
Else
 
  cmd.CommandText = "Insert into {xlh} (户号,姓名,身份证号,合作医疗证号,参合时间,缴费金额) select {hkxx}.户号,姓名,身份证号,医疗证号,\'" & d & "\',\'" & val & "\' from {hkxx} INNER JOIN {ylz} ON {hkxx}.户号 = {ylz}.户号  where r.Checked =true "
End If


End If
Next

cmd.ExecuteNonQuery
运行这段代码出错。我的主要上的是想让表中checkbox选中的记录才插入

--  作者:Bin
--  发布时间:2014/9/3 14:05:00
--  
不能这么做. 你用的是表序号哪里的复选框? 还是?
--  作者:有点甜
--  发布时间:2014/9/3 14:07:00
--  

 

参考来改。

 

Dim filter As String = ""
For Each r As Row In Tables("pl_Table1").GetCheckedRows
    filter &= "\'" & r("户号") & "\',"
Next

 

cmd.CommandText = "Insert into {xlh} (户号,姓名,身份证号,合作医疗证号,参合时间,缴费金额) select {hkxx}.户号,姓名,身份证号,医疗证号,\'" & d & "\',\'" & val & "\' from {hkxx} INNER JOIN {ylz} ON {hkxx}.户号 = {ylz}.户号  where {hkxx}.户号 in (" & filter.TrimEnd(",") & ")"


--  作者:riyuan
--  发布时间:2014/9/3 14:46:00
--  
谢谢。解决了