Link to home
Start Free TrialLog in
Avatar of TommyMac501
TommyMac501

asked on

What is wrong with this SQL statement?, C# is giving me errors..

I'm new to C#, but this SQL statement is giving me errors; "SQLException Unhandled, Incorrect syntax near "*""

Here is the code:

            SqlCommand command = conn.CreateCommand();
            command.CommandText = "DELETE * FROM MASTER";
            command.CommandType = CommandType.Text;

            SqlDataReader reader = command.ExecuteReader();

Since when can't I use an "*" in a SQL statement?  If I change the statement to a simple "DELETE FROM MASTER" it works fine.  - confused..
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

what is the database? not all database systems allow the * in the DELETE statement.
Avatar of TommyMac501
TommyMac501

ASKER

SQL Server.
Is that rule only for the SQLDataReader?.  I use the "*" in my queries all the time, including directly through the Query Analyzer.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oops.  duhhh..  Since I usually use the DELETE in conjunction with WHERE, I overlooked it.  I was thinking "TRUNCATE TABLE"..  My Bad...