Hi I'm new at this I have created a database Person with (ID,Name,address) in MS SQL
an d I have the following code
protected void Button1_Click(object sender, EventArgs e)
{
System.Data.SqlClient.SqlConnection conn =new System.Data.SqlClient.SqlConnection();
conn.ConnectionString ="integrated security=SSPI;data source=SQL Server Name;" +"persist security info=False;initial catalog=northwind";
try
{
conn.Open();
string sql = "DELETE FROM Person WHERE ID = 4"; //just as an example is number 4 taken
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.ExecuteNonQuery();
cmd.ExecuteScalar();
// Insert code to process data.
}
catch (Exception ex)
{
}
finally
{
conn.Close();
}
}
I work with Visual Studio 2005. it runs OK no error message but it does not deletes th Person with ID 4 .