Sql problem in C# ASP.NET



Hello,

I have made a Sql Statement, but it doesn't work. This is the
statement:

sqlStatementDataGrid = "SELECT * FROM Apparatuur WHERE ApparatuurID > "
+ lblPage.Text + " AND WHERE ApparatuurID <= " + (lblPage.Text + 5) ;

And this is the error:

Incorrect syntax near the keyword 'WHERE'.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax
near the keyword 'WHERE'.

Source Error:


Line 155: }
Line 156: SqlConnection MyConnection = new
SqlConnection(ConnectionString);
Line 157: dsDgrApparatuur = SqlHelper.ExecuteDataset(MyConnection,
CommandType.Text, sqlStatementDataGrid);
Line 158: dgrApparatuur.DataSource = dsDgrApparatuur;
Line 159: dgrApparatuur.DataBind();

Does anyone know what I'm doing wrong..?!

.



Relevant Pages

  • Re: Sql problem in C# ASP.NET
    ... > I have made a Sql Statement, ... > Incorrect syntax near the keyword 'WHERE'. ... > Exception Details: System.Data.SqlClient.SqlException: Incorrect syntax ...
    (comp.databases)
  • CREATE TYPE Error
    ... When I submit this SQL statement: ... I get an error message: ... Incorrect syntax near the keyword 'AS' ...
    (microsoft.public.sqlserver.programming)
  • Multiple Value List Bug...
    ... Incorrect syntax near the keyword 'SET'. ... statement must be terminated with a semicolon. ... an xmlnamespaces clause, the previous statement must be terminated ...
    (microsoft.public.sharepoint.portalserver.development)
  • Re: Collection cube ... view or table ?
    ... about error Incorrect syntax near the keyword 'as'. ... >> Wayne Snyder MCDBA, SQL Server MVP ...
    (microsoft.public.sqlserver.olap)
  • Re: Incorrect syntax near the keyword Close
    ... SQL Server MVP ... > Incorrect syntax near the keyword 'Close'. ... > Is this because those words are reserved words? ...
    (microsoft.public.sqlserver.server)