yossi
yossi

Reputation: 13325

System.Data.SqlClient.SqlException: Incorrect syntax near the keyword 'FROM'

Hi i am trying to create an insertion form in ASP.net. but i get this exception and i could not find this with google.

what am i doing wrong ?

here is my code:

<div id = "survey_div">
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
    ConnectionString="<%$ ConnectionStrings:surveyConnectionString1 %>" 
    DeleteCommand="DELETE FROM survey" 
    InsertCommand="INSERT INTO survey(age, country, city) VALUES (,,)" 
    SelectCommand="SELECT FROM survey" UpdateCommand="UPDATE survey SET">
</asp:SqlDataSource>

<asp:DetailsView ID="DetailsView1" runat="server" CellPadding="4" 
    DataSourceID="SqlDataSource1" EnableModelValidation="True" ForeColor="#333333" 
    GridLines="None" Height="50px" Width="125px">
    <AlternatingRowStyle BackColor="White" />
    <CommandRowStyle BackColor="#D1DDF1" Font-Bold="True" />
    <EditRowStyle BackColor="#2461BF" />
    <FieldHeaderStyle BackColor="#DEE8F5" Font-Bold="True" />
    <Fields>
        <asp:CommandField ShowInsertButton="True" />
    </Fields>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <RowStyle BackColor="#EFF3FB" />
</asp:DetailsView>
</div>

Upvotes: 0

Views: 6220

Answers (2)

Tron5000
Tron5000

Reputation: 854

It looks like the SelectCommand in your SqlDataSource is not specifying any columns to select:

SELECT FROM survey

Upvotes: 1

Brian Ball
Brian Ball

Reputation: 12606

It looks like it's your SelectCommand, you need to either have a list of columns, or * between Select and From (preferably a list of columns).

Upvotes: 5

Related Questions