Click here to Skip to main content
15,877,565 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
SqlConnection con = new SqlConnection();
                con.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=d:\users\vivek\documents\visual studio 2010\Projects\soft\soft\database\vks.mdf;Integrated Security=True;User Instance=True";
                string str;
                str = "insert into qualification_master (qualification_name) values('" + comboBox1.Text + "')";
                con.Open();
                SqlCommand cmd = new SqlCommand(str, con);
                cmd.ExecuteNonQuery();

what change in above code for delete data ?
Posted
Updated 4-Aug-11 0:02am
v2

First, format your code using code blocks.
Second, use parameterized queries, your code is susceptible to SQL Injection attacks.

Here is the answer.
SQL
DELETE FROM qualification_master WHERE qualification_name = @yourValue
 
Share this answer
 
Looks like you have no idea about sql queries.
str = "DELETE FROM qualification_master WHERE qualification_name = '" + comboBox1.Text + "'";

If you have primary key in table, you have to use that in where condition.

Check this for delete query.

http://www.w3schools.com/sql/sql_delete.asp[^]

To learn sql start from here[^].
 
Share this answer
 
v2
Comments
UJimbo 4-Aug-11 6:06am    
pretty much
vivek shaushi 4-Aug-11 6:07am    
but which method i can use cmd.executenonquery or other????
Toniyo Jackson 4-Aug-11 6:09am    
cmd.executenonquery
koolprasad2003 4-Aug-11 6:10am    
Use ExecuteNonQuery() method which will return you Integer value.
vivek shaushi 4-Aug-11 6:10am    
thanx bro
DELETE FROM qualification_master


Trust me this will delete all the data from table. Don't use
Where

clause and never use parametrized query in .Net.

Please guys don't post answer to these type questions.
This guy even don't know the SQL command, how can we help this guy?

He want help on SQL (subject: delete data) has a tag of C#.
 
Share this answer
 
Comments
vivek shaushi 4-Aug-11 6:12am    
tari ma no bhosdo
Toniyo Jackson 4-Aug-11 6:15am    
What are you talking man? If you don't know something only you will come here. Just help him in a right way. See my answer. I given him the answer and given some links to learn sql also. We have to help new guys.
Suresh Suthar 4-Aug-11 6:21am    
Just see the comment by the guy you helped.

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