Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
table name Comparess
database name Proge144

I want to delete a table in sql database with c#.
(Not Data in Comparess table)


please Help me
Posted
Comments
Maciej Los 22-Feb-15 15:33pm    
And an issue is...
Kuthuparakkal 22-Feb-15 16:15pm    
https://msdn.microsoft.com/en-us/library/ms162575.aspx
PIEBALDconsult 22-Feb-15 17:23pm    
Might be nice to know database system. Is it at least an SQL database?

You can use ADO.NET and just execute the DROP TABLE SQL command.

C#
using (SqlConnection connection = new SqlConnection(
           connectionString))
{
    SqlCommand command = new SqlCommand("DROP TABLE Comparess", connection);
    command.Connection.Open();
    command.ExecuteNonQuery();
    command.Connection.Close();
}
 
Share this answer
 
Drop a table and check if the statement succeeded -

C#
con.open();
string str=" Drop table compass";
cmd= new SqlCommand(str,con);
int r=cmd.executenonquery();
if(r<0)
{
  //Dropped successfully
}
else
{
  //There was an error
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900