Incorrect syntax near 'nvarchar'.

Discussion in 'ASP .Net' started by Mark B, Aug 6, 2008.

  1. Mark B

    Mark B Guest

    When I click the 'Update' button on a ASP.Net 3.5 GridView record, I get an
    error:

    Incorrect syntax near 'nvarchar'.

    Everything else there works OK. Here is the code:


    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="default.aspx.vb"
    Inherits="pages_verify_groups_Default" Debug="true"
    MasterPageFile="~/pages/master_page/MasterPage.master"
    Title="Page1"%>

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolderMain1"
    Runat="Server">

    </tr><tr><td><h2>


    Title</h2>
    <p>


    <asp:GridView
    ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="SqlDataSource1"
    AllowPaging="True" AllowSorting="True">
    <Columns>
    <asp:CommandField
    ShowEditButton="True" />
    <asp:BoundField
    DataField="ID" HeaderText="ID" InsertVisible="False"
    ReadOnly="True"
    SortExpression="ID" />
    <asp:BoundField
    DataField="Language" HeaderText="Language"
    SortExpression="Language"
    />
    <asp:BoundField
    DataField="English ID" HeaderText="English ID"
    SortExpression="English
    ID" />
    <asp:BoundField
    DataField="English" HeaderText="English"
    SortExpression="English"
    />
    <asp:BoundField
    DataField="Text" HeaderText="Text" SortExpression="Text" />
    </Columns>
    </asp:GridView>
    <asp:SqlDataSource
    ID="SqlDataSource1" runat="server"
    ConnectionString="<%$
    ConnectionStrings:MyConnectionString %>"

    SelectCommand="SELECT
    tblLanguageValues.AutoNumberID AS ID, tblLanguageValues.LanguageCode AS
    Language, tblLanguageValues.LookupID AS [English ID],
    tblLanguageValues_1.LanguageText AS English, tblLanguageValues.LanguageText
    AS Text FROM tblLanguageValues INNER JOIN tblLanguageValues AS
    tblLanguageValues_1 ON tblLanguageValues.LookupID =
    tblLanguageValues_1.AutoNumberID WHERE (tblLanguageValues.LanguageCode =
    'FR-FR')"

    UpdateCommand="UPDATE
    tblLanguageValues SET LanguageText = @LanguageText WHERE (LanguageCode =
    @LanguageCode) AND (LookupID = @LookupID)">
    <UpdateParameters>
    <asp:parameter
    Name="LanguageText" type="String" />
    <asp:parameter
    Name="LanguageCode" type="String"/>
    <asp:parameter
    Name="LookupID" type="Int32" />
    </UpdateParameters>
    </asp:SqlDataSource>
    </p>
    </td>
    </tr>
    <tr>
    <td>
    <p>
    </p>
    </td>
    </tr>
    <tr>
    <td>
    &nbsp;</td>
    </tr>
    <tr>
    <td>

    </td>
    </tr>
    <tr>
    <td>
    &nbsp;</td>
    </tr>
    <tr>
    <td>
    &nbsp;</td>
    </tr>
    <tr>
    <td>
    &nbsp;</td>
    </tr>
    </asp:Content>
    <asp:Content ID="Content2" runat="server" contentplaceholderid="head">

    </asp:Content>
     
    Mark B, Aug 6, 2008
    #1
    1. Advertising

  2. Mark B

    Munna Guest

    Munna, Aug 6, 2008
    #2
    1. Advertising

  3. Mark B

    Mark B Guest

    UPDATE [dbo].[tblLanguageValues]
    SET [LanguageCode] = <LanguageCode, varchar(10),>
    ,[LookupID] = <LookupID, int,>
    ,[LanguageText] = <LanguageText, nvarchar(4000),>
    WHERE <Search Conditions,,>


    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    SET ANSI_PADDING ON
    GO
    CREATE TABLE [dbo].[tblLanguageValues](
    [AutoNumberID] [int] IDENTITY(1,1) NOT NULL,
    [LanguageCode] [varchar](10) NOT NULL CONSTRAINT
    [DF_tblLanguageValues_LanguageCode] DEFAULT ('EN-US'),
    [LookupID] [int] NOT NULL,
    [LanguageText] [nvarchar](4000) NOT NULL,
    CONSTRAINT [PK_tblLanguageValues] PRIMARY KEY CLUSTERED
    (
    [LanguageCode] ASC,
    [LookupID] ASC
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY =
    OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    GO
    SET ANSI_PADDING OFF




    "Munna" <> wrote in message
    news:...
    > Hi
    >
    > This is a invalid sql string message... your update sql string have
    > some problem...
    > check that your database columns datatype and sql string is good...
    >
    > Best of luck
    >
    > -------
    > Munna
    >
    > www.munna.shatkotha.com/blog
    > www.munna.shatkotha.com
    > www.shatkotha.com
     
    Mark B, Aug 6, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,745
    Patrick.O.Ige
    Oct 11, 2004
  2. Patrick Olurotimi Ige
    Replies:
    4
    Views:
    7,046
    Patrick Olurotimi Ige
    Mar 18, 2005
  3. JMUApache
    Replies:
    2
    Views:
    3,320
    Brendan Reynolds
    Sep 4, 2005
  4. David

    Incorrect syntax near 'int'

    David, Apr 6, 2006, in forum: ASP .Net
    Replies:
    7
    Views:
    2,491
    David
    Apr 7, 2006
  5. Kevin Bilbee

    Incorrect syntax near 'nvarchar'.

    Kevin Bilbee, Jan 9, 2008, in forum: ASP .Net
    Replies:
    5
    Views:
    810
    Kevin Bilbee
    Jan 27, 2008
Loading...

Share This Page