我要执行下面的sql语句,提示错误: 值不能为null,参数: key, 要如何修改
下面的代码我将查询词改成Sele*,是为了能保存到论坛中,测式时请补充改成。
这个查询表语句我不设主键,在foxtable的执行sql窗口中是可以执行的,能看到表格。
Dim sqls As String = "Sele* 记录合计.机构编号, 最后一条记录.学生编号, 最后一条记录.姓名, 最后一条记录.总分,"
sqls += " 记录合计.得分"
sqls += " FROM (Sele* 记录.学生编号, 记录.姓名, 记录.记分, 记录.总分"
sqls += " FROM 记录 INNER JOIN"
sql += " (Sele* MAX(id) As id, 学生编号"
sql += " FROM 记录 As 记录_2"
sql += " GROUP BY 学生编号) As tablea ON 记录.id = tablea.id"
sqls += " WHERE (记录.时间 BETWEEN '1/1/2022' AND '2/19/2022')) AS 最后一条记录 INNER JOIN"
sqls += " (Sele* 学生编号, 姓名, 机构编号, SUM(记分) As 得分"
sqls += " FROM 记录 As 记录_1"
sqls += " WHERE (时间 BETWEEN '1/1/2022' AND '2/20/2022')"
sqls += " GROUP BY 学生编号, 姓名, 机构编号) As 记录合计 ON 最后一条记录.学生编号 = 记录合计.学生编号 And "
sqls += " 记录合计.机构编号 = 6 "
sqls += " ORDER BY 最后一条记录.总分 DESC "
Dim cmd As New SQLCommand
cmd.C
cmd.BeginTransaction() '开启事务
cmd.CommandText = sql
dt = cmd.ExecuteReader()
cmd.Commit() '提交事务
[此贴子已经被作者于2022/2/19 13:30:17编辑过]