C# Delete database records without SQL text?

  • Thread starter Thread starter Danny
  • Start date Start date
D

Danny

Hi all,

I need to delete rows from my db, when the criteria is: older than a
certain date.
Can it be done without an SQL string query?? Using only a DataSet
and/or DataAdapter?

The regular SQL would be: "DELETE FROM EventLog WHERE
EL_TimeStamp<01/08/2006".
But the problem is using the date in C# and Access-database.

Thanks in advance,
Danny
 
Danny said:
I need to delete rows from my db, when the criteria is: older than a
certain date.
Can it be done without an SQL string query?? Using only a DataSet
and/or DataAdapter?

The regular SQL would be: "DELETE FROM EventLog WHERE
EL_TimeStamp<01/08/2006".
But the problem is using the date in C# and Access-database.

Rather than embedding the date directly into the SQL, use a
parameterised SQL statement.

See http://www.pobox.com/~skeet/csharp/faq/#db.parameters
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top