查询表格,然后addNew,最后保存,出不能为空的报错信息, 即使去掉过滤条件,有查询记录,也报这个错误
代码:
' 写入数据库
Dim cmd As New SQLCommand
Dim strSQL As String
cmd.C
'Try
Output.Show("11111111111")
' 如果重算,则删除当天数据
If bCalAll Then
strSQL = "dele te dbdayCard where YYMMDD = '" & queryDate.ToString & "'"
cmd.CommandText = strSQL
cmd.ExecuteNonQuery()
End If
Output.Show("222222222222")
' 选择一个空表
strSQL = "sele ct empNo , empName , workHour , partNo , dtName1 , dtName2 , dtName3 , dtName4 , dtName5 , dtName6 , 可用, 创建者 , 创建时间 , 修改者, 修改时间 , YYMMDD , workType , Leader , workZone "
strSQL = strSQL & Chr(13) & "from {dbdayCard} where [_identify] is null "
cmd.CommandText = strSQL
Output.Show(strSQL)
Dim dt As DataTable = cmd.ExecuteReader(True)
Output.Show("333333333333")
' 填充数据
For Each dr As DataRow In dbData.DataRows
Dim drNew As DataRow = dt.AddNew()
For Each dc As DataCol In dbData.DataCols
drNew(dc.Name) = dr(dc.Name)
Next
Next
Output.Show("44444444444444")
' 保存
dt.Save()
Output.Show("555555555555555")
'Catch ex As Exception
' Output.Show( "try:" & ex.Message)
' End Try
输出:
11111111111
222222222222
sel ect empNo , empName , workHour , partNo , dtName1 , dtName2 , dtName3 , dtName4 , dtName5 , dtName6 , 可用, 创建者 , 创建时间 , 修改者, 修改时间 , YYMMDD , workType , Leader , workZone
from {dbdayCard} where [_identify] is null
errlog:
2024-06-22 09:32:28.7197
事件/函数:自定义函数,跨天
调用的目标发生了异常。
在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
在 Foxtable.UserFunctions.Execute(String Name, Object[] Args)
对于不返回任何键列信息的 Selec tCommand,不支持 Upd ateCommand 的动态 SQL 生成。
在 System.Data.Common.DbCommandBuilder.IncludeInWhereClause(DbSchemaRow row, Boolean isUpd ate)
在 System.Data.Common.DbCommandBuilder.BuildWhereClause(DataTableMapping mappings, DataRow dataRow, StringBuilder builder, DbCommand command, Int32 parameterCount, Boolean isUpda te)
在 System.Data.Common.DbCommandBuilder.BuildUpd ateCommand(DataTableMapping mappings, DataRow dataRow)
在 System.Data.Common.DbCommandBuilder.GetUpd ateCommand(DataRow dataRow, Boolean useColumnsForParameterNames)
在 System.Data.OleDb.OleDbCommandBuilder.GetUpd ateCommand()
在 Foxtable.oO_OOO0oo.o_o.o0_ooO__.(OleDbDataAdapter A_0)
在 Foxtable.SQLCommand.ExecuteReader(Boolean Save)
在 UserCode.ArjjeFtI1GPdhcx9X(Object[] Args)
[此贴子已经被作者于2024/6/22 9:48:26编辑过]