Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
 

 
<%@ 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 14-Jun-12 20:13pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this Link this is in C# but you can convert it into vb.net Online
[^]
 
for C# to VB.NET
[^]
  Permalink  
v2

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

  Print Answers RSS
0 CPallini 375
1 Sergey Alexandrovich Kryukov 370
2 BillWoodruff 314
3 George Jonsson 279
4 OriginalGriff 257
0 OriginalGriff 5,030
1 CPallini 4,115
2 Sergey Alexandrovich Kryukov 3,554
3 George Jonsson 2,826
4 Gihan Liyanage 2,386


Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 15 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100