rito1
asked on
Syntax error in UPDATE statement Using OleDb and MS Access
Hi,
I have used VS 2005 to create an update statement to an Access table but it is throwing the following error:
System.Data.OleDb.OleDbExc eption: Syntax error in UPDATE statement.
The AccessDataSource control's SQL Statement and parameters look like so...
UpdateCommand="UPDATE [tblCustomers] SET [Customer_name] = ?, [Customer_Username] = ?, [Customer_Password] = ?, [Customer_Live] = ?, WHERE [CustomerID] = ?"
Parameters -
<UpdateParameters>
<asp:Parameter Name="Customer_name" Type="String" />
<asp:Parameter Name="Customer_Username" Type="String" />
<asp:Parameter Name="Customer_Password" Type="String" />
<asp:Parameter Name="Customer_Live" Type="Boolean" />
<asp:Parameter Name="CustomerID" Type="Int32" />
</UpdateParameters>
Is anyone able to see any issues?
Many thanks,
Rit
I have used VS 2005 to create an update statement to an Access table but it is throwing the following error:
System.Data.OleDb.OleDbExc
The AccessDataSource control's SQL Statement and parameters look like so...
UpdateCommand="UPDATE [tblCustomers] SET [Customer_name] = ?, [Customer_Username] = ?, [Customer_Password] = ?, [Customer_Live] = ?, WHERE [CustomerID] = ?"
Parameters -
<UpdateParameters>
<asp:Parameter Name="Customer_name" Type="String" />
<asp:Parameter Name="Customer_Username" Type="String" />
<asp:Parameter Name="Customer_Password" Type="String" />
<asp:Parameter Name="Customer_Live" Type="Boolean" />
<asp:Parameter Name="CustomerID" Type="Int32" />
</UpdateParameters>
Is anyone able to see any issues?
Many thanks,
Rit
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you need to still add single quotes in the query:
UpdateCommand="UPDATE [tblCustomers] SET [Customer_name] = ' " + <GridViewValue> + " ' "
UpdateCommand="UPDATE [tblCustomers] SET [Customer_name] = ' " + <GridViewValue> + " ' "
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
emoreau, Yes you got it. I think that is the problem.
ASKER
Thanks emoreau, I would have been there for ages! Thanks rpkhare for your support too.
ASKER
The string values are coming straigh from the Gridview as I am using the Update command button.
The data type Customer_Live was Yes/No but have just changed it to True/False but still getting this error.
My gridview looks like this...
Open in new window