Ankita Ankita

Ankita Ankita

  • NA
  • 11
  • 28k

C# code to drop a table?

Mar 12 2012 4:35 AM
In following if condition is getting false n control jumps to else. Is my condition wrong? I get o/p as "Table is not dropped". what value is returned by executenonquery method for drop table?

con is object of sqlconnection.
cmd is object of sqlcommand


con.open();
string str=" Drop table temp";
cmd= new SqlCommand(str,con);
int r=cmd.executenonquery();
if(r>0)
{

       messagebox.show("Table is dropped");

}
else
{

    messagebox.show("Table is not dropped");
}

Answers (2)