"Darryn Ross" <da****@datawave.com.au> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
Hi
I need to run a delete query from my application... is there a quick way
of doing this other than setting up an adapter and running the stored
procedure?? etc...
something like the VB6 database.Execute(SQLStatement) would be perfect...
if not i'll just do i the normal way.
Thanks
Regards
You need to set up a connection to your database, which here is referenced
by oleDbConnection1, this code is for an OLEDB connection but this can
easily be replaced by the SQL version.
string strDelete = "DELETE FROM [yourDatabase] WHERE [yourField] = '" +
yourArgument + "'";
OleDbCommand cmd = new OleDbCommand(strDelete, oleDbConnection1);
try
{
oleDbConnection1.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
}
finally
{
oleDbConnection1.Close();
}