Invalidoperationexpression未处理 - OleDbCommand.Prepare方法要求所有参数都具有显式设置类型

时间:2015-01-09 14:15:51

标签: vb.net

我正在尝试更新数据库,但一直在标题中收到错误。这里的任何想法都是相关的代码:

IDValue = Login.lb.Text
lblIDRunner.Text = IDValue

dbProvider = "PROVIDER=Microsoft.ACE.OLEDB.12.0;"
dbSource = "Data Source = H:\Computer Project\bin\Debug\projectdatabase.accdb"

RunnerConnection.ConnectionString = dbProvider & dbSource

RunnerConnection.Open()

sqlQuery = "SELECT * FROM tblDetails Where RunnerID = @RunnerID"
daRunnerDetails = New OleDb.OleDbDataAdapter(sqlQuery, RunnerConnection)
daRunnerDetails.SelectCommand.Parameters.AddWithValue("@RunnerID", lblIDRunner.Text)
daRunnerDetails.Fill(dsRunnerDetails, "Details")
RunnerConnection.Close()
Dim cbRunners As New OleDb.OleDbCommandBuilder(daRunnerDetails)


dsRunnerDetails.Tables("Details").Rows(0).Item(1) = txtUserFirstname.Text
dsRunnerDetails.Tables("Details").Rows(0).Item(2) = txtuserlastname.Text
dsRunnerDetails.Tables("Details").Rows(0).Item(3) = txtUserDOB.Text
dsRunnerDetails.Tables("Details").Rows(0).Item(4) = txtUserEmail.Text
dsRunnerDetails.Tables("Details").Rows(0).Item(5) = txtUserNumber.Text
dsRunnerDetails.Tables("Details").Rows(0).Item(6) = txtUserGender.Text
dsRunnerDetails.Tables("Details").Rows(0).Item(7) = txtUserWeight.Text
daRunnerDetails.Update(dsRunnerDetails, "Details")
MsgBox("Data updated")
RunnerConnection.Close()

0 个答案:

没有答案