Dim connectionstring As String
Dim strconnection As OleDbConnection
connectionstring = "provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("data\stumaneger.mdb")
strconnection = New OleDbConnection(connectionstring)
Dim insertcommand As String
Dim name As String, describe As String, teachid As String
name = TextBox2.Text
describe = TextBox3.Text
'insertcommand = "insert into Class(Class_name,Class_teachid,Class_describe) values(@name,@teachid,@describe)"
Dim strcommand1 As OleDbCommand
strcommand1 = New OleDbCommand(insertcommand, strconnection)
strcommand1.Parameters.Add("@name", OleDbType.VarChar, 15)
strcommand1.Parameters.Add("@teachid", OleDbType.VarChar, 15)
strcommand1.Parameters.Add("@describe", OleDbType.VarChar, 200)
strcommand1.Parameters("@name").Value = name
'strcommand1.Parameters("@teachid").Value = teachid
'strcommand1.Parameters("@describe").Value = describe
strcommand1.Connection.Open()
strcommand1.ExecuteNonQuery()
strcommand1.Connection.Close()
哪位高手指导一下我这菜鸟这是一个有四个字段的表第一个字段是自动编号的
Class_name是必填字段,Class_teachid和Class_describe非必填字段
而且Class_teachid现在是不用添加的
我做运行的时候错误显示是:
查询值的数目与目标字段中的数目不同。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Data.OleDb.OleDbException: 查询值的数目与目标字段中的数目不同。
源错误:
行 70:
行 71: strcommand1.Connection.Open()
行 72: strcommand1.ExecuteNonQuery()
行 73: strcommand1.Connection.Close()
行 74: