Solved

Syntax error in UPDATE statement Using OleDb and MS Access

Posted on 2008-10-27
6
1,009 Views
Last Modified: 2010-04-21
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.OleDbException: 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
0
Comment
Question by:rito1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Assisted Solution

by:rpkhare
rpkhare earned 150 total points
ID: 22811340
Are you supplying string values as:

'Customer Name'

One other possibility I guess is the Boolean DataType. In Access it is Yes/No. What you are supplying?
0
 
LVL 1

Author Comment

by:rito1
ID: 22811422
Hi rpkhare

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...



<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CustomerID" DataSourceID="AccessDataSource1" Width="100%" CellPadding="4" AlternatingRowStyle-BackColor="#eeeeee" BorderWidth="1px" BorderColor="#EEEEEE">
        <Columns>
            <asp:BoundField DataField="Customer_name" HeaderText="Customer Name" SortExpression="Customer_name" />
            <asp:BoundField DataField="Customer_Username" HeaderText="Username" SortExpression="Customer_Username" />
            <asp:BoundField DataField="Customer_Password" HeaderText="Password" SortExpression="Customer_Password" />
            <asp:CheckBoxField DataField="Customer_Live" HeaderText="Live?" SortExpression="Customer_Live" />
            <asp:CommandField ShowEditButton="True" />
            <asp:TemplateField ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" Text=" X " OnClientClick="return confirm('Are you sure you want to delete this record?');" ForeColor="red"></asp:LinkButton>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

Open in new window

0
 
LVL 8

Expert Comment

by:rpkhare
ID: 22811492
I think you need to still add single quotes in the query:

UpdateCommand="UPDATE [tblCustomers] SET [Customer_name] = ' " + <GridViewValue> + " ' "
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 350 total points
ID: 22811507
remove the comma just before the WHERE
0
 
LVL 8

Expert Comment

by:rpkhare
ID: 22811516
emoreau, Yes you got it. I think that is the problem.
0
 
LVL 1

Author Closing Comment

by:rito1
ID: 31510245
Thanks emoreau, I would have been there for ages! Thanks rpkhare for your support too.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question