日期:2014-05-18 浏览次数:20717 次
Dim zd1 As String, zd2 As String, zd3 As String, zd4 As String, zd5 As String, zd6 As String For s = 0 To myDataset1.Tables(0).Rows.Count - 1 zd1 = myDataset1.Tables(0).Rows(s).Item("字段1") & "" zd2 = myDataset1.Tables(0).Rows(s).Item("字段2") & "" zd3 = myDataset1.Tables(0).Rows(s).Item("字段3") & "" zd4 = myDataset1.Tables(0).Rows(s).Item("字段4") & "" zd5 = myDataset1.Tables(0).Rows(s).Item("字段5") & "" zd6 = myDataset1.Tables(0).Rows(s).Item("字段6") & "" sql = "INSERT INTO table(字段1,字段2,字段3,字段4,字段5,字段6) VALUES('" & zd1 & "','" & zd2 & "', '" & zd3 & "','" & zd4 & "','" & zd5 & "','" & zd6 & "')" MyCommand = New OleDbCommand(sql, cn) MyCommand.ExecuteNonQuery() Next
------解决方案--------------------
string sql = "insert into 成绩 (成绩表字段1,成绩表字段2)values(@xuhao,@name)";
------解决方案--------------------
插入语句中没有表的字段
改为:
string sql = "insert into 成绩 (成绩表字段1,成绩表字段2)values(@xuhao,@name)";