AccessDataSource更新与where条件

时间:2013-05-29 02:56:17

标签: asp.net sql ms-access

尝试使用visual studio更新asp中的访问数据库。

Dim accessDatabase2 As New AccessDataSource
accessDatabase2 = New AccessDataSource("Prestiege.accdb", "SELECT * FROM Rooms ;")
accessDatabase2.UpdateCommand = "UPDATE [Rooms] SET [Occupancy] = 1 Where [RoomType] = Single ;"
accessDatabase2.Update()

如果我删除 where condition ,它可以正常工作。否则我会收到此错误:

Exception Details: System.Data.OleDb.OleDbException: No value given for one or more   required parameters.

任何人都可以帮我吗?

1 个答案:

答案 0 :(得分:1)

在给出字符串参数

时尝试使用单引号
accessDatabase2.UpdateCommand = "UPDATE [Rooms] SET [Occupancy] = 1 Where [RoomType] = 'Single';"