Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Syntax error in UPDATE statement Using OleDb and MS Access

Posted on 2008-10-27
6
Medium Priority
?
1,014 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 600 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 70

Accepted Solution

by:
Éric Moreau earned 1400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

715 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