Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HEY FRIEND I AM USING vb.net 2008 in grid view by using sqldatasourc in which i am enable to insert delete and update option then run my project when i am going to update they show me error
Incorrect syntax near 'nvarchar'.

grid view and datasource code show below pls do need full me



XML
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
        CellPadding="3" DataKeyNames="ID" DataSourceID="SqlDataSource1"
        GridLines="Horizontal" AllowSorting="True">
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <EmptyDataRowStyle BackColor="Red" />
        <Columns>
            <asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
                ReadOnly="True" SortExpression="ID" />
            <asp:BoundField DataField="Date" HeaderText="Date" SortExpression="Date" />
            <asp:BoundField DataField="Shift" HeaderText="Shift" SortExpression="Shift" />
            <asp:BoundField DataField="Area" HeaderText="Area" SortExpression="Area" />
            <asp:BoundField DataField="Equipment" HeaderText="Equipment"
                SortExpression="Equipment" />
            <asp:BoundField DataField="Sub Equipment" HeaderText="Sub Equipment"
                SortExpression="Sub Equipment" />
            <asp:BoundField DataField="Category" HeaderText="Category"
                SortExpression="Category" />
            <asp:BoundField DataField="Observations/Abnormalities"
                HeaderText="Observations/Abnormalities"
                SortExpression="Observations/Abnormalities" />
            <asp:BoundField DataField="Reported By" HeaderText="Reported By"
                SortExpression="Reported By" />
            <asp:BoundField DataField="Responsible Department"
                HeaderText="Responsible Department" SortExpression="Responsible Department" />
            <asp:BoundField DataField="Reported To" HeaderText="Reported To"
                SortExpression="Reported To" />
            <asp:BoundField DataField="Action Taken" HeaderText="Action Taken"
                SortExpression="Action Taken" />
            <asp:BoundField DataField="Action Taken By" HeaderText="Action Taken By"
                SortExpression="Action Taken By" />
            <asp:BoundField DataField="Date Of Completion" HeaderText="Date Of Completion"
                SortExpression="Date Of Completion" />
            <asp:BoundField DataField="Remarks" HeaderText="Remarks"
                SortExpression="Remarks" />
        </Columns>
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:EMS_60042ConnectionString %>"
        DeleteCommand="DELETE FROM [Tbl_AbnormalityReport] WHERE [ID] = @original_ID"
        InsertCommand="INSERT INTO [Tbl_AbnormalityReport] ([Date], [Shift], [Area], [Equipment], [Sub Equipment], [Category], [Observations/Abnormalities], [Reported By], [Responsible Department], [Reported To], [Action Taken], [Action Taken By], [Date Of Completion], [Remarks]) VALUES (@Date, @Shift, @Area, @Equipment, @Sub_Equipment, @Category, @column1, @Reported_By, @Responsible_Department, @Reported_To, @Action_Taken, @Action_Taken_By, @Date_Of_Completion, @Remarks)"
        OldValuesParameterFormatString="original_{0}"
        SelectCommand="SELECT * FROM [Tbl_AbnormalityReport]"

        UpdateCommand="UPDATE [Tbl_AbnormalityReport] SET [Date] = @Date, [Shift] = @Shift, [Area] = @Area, [Equipment] = @Equipment, [Sub Equipment] = @Sub_Equipment, [Category] = @Category, [Observations/Abnormalities] = @column1, [Reported By] = @Reported_By, [Responsible Department] = @Responsible_Department, [Reported To] = @Reported_To, [Action Taken] = @Action_Taken, [Action Taken By] = @Action_Taken_By, [Date Of Completion] = @Date_Of_Completion, [Remarks] = @Remarks WHERE [ID] = @original_ID">
        <DeleteParameters>
            <asp:Parameter Name="original_ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter DbType="Date" Name="Date" />
            <asp:Parameter Name="Shift" Type="String"  />
            <asp:Parameter Name="Area" Type="String" />
            <asp:Parameter Name="Equipment" Type="String" />
            <asp:Parameter Name="Sub_Equipment" Type="String" />
            <asp:Parameter Name="Category" Type="String" />
            <asp:Parameter Name="column1" Type="String" />
            <asp:Parameter Name="Reported_By" Type="String" />
            <asp:Parameter Name="Responsible_Department" Type="String" />
            <asp:Parameter Name="Reported_To" Type="String" />
            <asp:Parameter Name="Action_Taken" Type="String" />
            <asp:Parameter Name="Action_Taken_By" Type="String" />
            <asp:Parameter DbType="Date" Name="Date_Of_Completion" />
            <asp:Parameter Name="Remarks" Type="String" />
            <asp:Parameter Name="original_ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter DbType="Date" Name="Date" />
            <asp:Parameter Name="Shift" Type="String" />
            <asp:Parameter Name="Area" Type="String" />
            <asp:Parameter Name="Equipment" Type="String" />
            <asp:Parameter Name="Sub_Equipment" Type="String" />
            <asp:Parameter Name="Category" Type="String" />
            <asp:Parameter Name="column1" Type="String" />
            <asp:Parameter Name="Reported_By" Type="String" />
            <asp:Parameter Name="Responsible_Department" Type="String" />
            <asp:Parameter Name="Reported_To" Type="String" />
            <asp:Parameter Name="Action_Taken" Type="String" />
            <asp:Parameter Name="Action_Taken_By" Type="String" />
            <asp:Parameter DbType="Date" Name="Date_Of_Completion" />
            <asp:Parameter Name="Remarks" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
    </form>
</body>
</html>
Posted

1 solution

try this Link this is in C# but you can convert it into vb.net Online
[^]

for C# to VB.NET
[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900