Hello all,
I have written code for deleting particular Id entered by the user in the text box. What i need is when i press on Delete button it should display if the Entered Id delete or not. can any one give me the code. I am able to delete but that condition i am unable to get. Please help
Loading

Kirtan PatelPosted May 22, 2009, 11:47 AM
with three Column
ID,Name,Age
Then Code will be like below
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True");
con.Open();
SqlCommand comm = new SqlCommand("select * from Users Where Id=" + textBox1.Text, con);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataSet ds = new DataSet();
da.Fill(ds, "Vtable");
if (ds.Tables[0].Rows.Count > 0)
{
comm = new SqlCommand("delete from users where id=" + textBox1.Text,con);
comm.ExecuteNonQuery();
MessageBox.Show("Record Deleted!!");
}
else
{
MessageBox.Show("Record Not Exist");
}
}
Kirtan PatelPosted May 23, 2009, 2:55 AM
You can name it Anything But I call it Virtual Table so called "VTable"
Dorababu MekaPosted May 23, 2009, 12:05 AM