Monday, March 26, 2012

Incorrect syntax near the keyword FROM.

Getting this error.. the page runs fine but it after entering the data it produces the following..

ERROR: Incorrect syntax near the keyword 'FROM'.
with the following code...Please help!

<headrunat="server">
<title>Parts Lookup</title>
</head>
<bodystyle="text-align: center">
<formid="form1"runat="server">
<divstyle="text-align: center">
<br/>
<brpanstyle="font-size: 10pt; font-family: Tahoma">

Enter a Part Number</span>

<asp:TextBoxID="Productnbr"runat="server"Columns="4"Width="177px"></asp:TextBox><br/>
<asp:ButtonID="DisplayPartNumberButton"runat="server"Text="Display Price, Description, Unit of Measure"Font-Names="Tahoma"/><br/>

<br/>

</div>
<asp:GridViewID="GridView1"runat="server"AutoGenerateColumns="False"DataSourceID="PartFilterDataSource"EnableViewState="False"Width="431px"CellPadding="4"ForeColor="#333333"GridLines="None"Font-Bold="False">
<Columns>
<asp:BoundFieldDataField="PartNbr"HeaderText="Part Number"SortExpression="PartNbr"/>
<asp:BoundFieldDataField="Description"HeaderText="Description"SortExpression="Description"/>
<asp:BoundFieldDataField="Price"HeaderText="Price"SortExpression="Price"/>
<asp:BoundFieldDataField="UnitOfMeasure"HeaderText="Unit of Measure"SortExpression="UnitOfMeasure"/>
</Columns>
<FooterStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/>
<RowStyleBackColor="#F7F6F3"ForeColor="#333333"/>
<EditRowStyleBackColor="#999999"/>
<SelectedRowStyleBackColor="#E2DED6"Font-Bold="True"ForeColor="#333333"/>
<PagerStyleBackColor="#284775"ForeColor="White"HorizontalAlign="Center"/>
<HeaderStyleBackColor="#5D7B9D"Font-Bold="True"ForeColor="White"/>
<AlternatingRowStyleBackColor="White"ForeColor="#284775"/>
</asp:GridView>

<asp:SqlDataSourceID="PartFilterDataSource"runat="server"
ConnectionString="<%$ ConnectionStrings:ManManSQLConnectionString %>"
SelectCommand=
"SELECT PartNbr, Description, UnitOfMeasure, Price; FROM Tbl_ODBC_PartsList; WHERE PartNbr = @.Productnbr">
<SelectParameters>
<asp:ControlParameterControlID="Productnbr"Name="Productnbr"PropertyName="Text"/>
</SelectParameters>
</asp:SqlDataSource>
</form>
</body>
</html>

there is a semicolon after price. remove the semicolon

|||

Try this one if you have a column named as Productnbr:

SelectCommand="SELECT PartNbr, Description, UnitOfMeasure, Price FROM Tbl_ODBC_PartsList WHERE Productnbr = @.Productnbr">

<SelectParameters>
<asp:ControlParameterControlID="Productnbr"Name="Productnbr"PropertyName="Text"/>
</SelectParameters>

Or If you don't have a column named as Productnbr:

SelectCommand=
"SELECT PartNbr, Description, UnitOfMeasure, Price FROM Tbl_ODBC_PartsList WHERE PartNbr = @.PartNbr">
<SelectParameters>
<asp:ControlParameterControlID="Productnbr"Name="PartNbr"PropertyName="Text"/>
</SelectParameters>


sql

No comments:

Post a Comment