• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

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..
0
TommyMac501
Asked:
TommyMac501
  • 3
  • 3
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what is the database? not all database systems allow the * in the DELETE statement.
0
 
TommyMac501Author Commented:
SQL Server.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
for the reference:
http://msdn.microsoft.com/en-us/library/ms189835.aspx
sql server does not allow the *

while ms access does:
http://msdn.microsoft.com/en-us/library/bb177896.aspx
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TommyMac501Author Commented:
Is that rule only for the SQLDataReader?.  I use the "*" in my queries all the time, including directly through the Query Analyzer.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>is that rule only for the SQLDataReader?
no, it's for sql server overall.
note: for the DELETE statement...
for SELECT it is perfectly possible

0
 
TommyMac501Author Commented:
oops.  duhhh..  Since I usually use the DELETE in conjunction with WHERE, I overlooked it.  I was thinking "TRUNCATE TABLE"..  My Bad...

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now