Possible Duplicate:
Pros and Cons of using SqlCommand Prepare in C#?
Here is an example. This seems to work fine but I just stumbled upon Prepare() and I'm wondering if I should be using it.
con.Open();
cmd.Connection = con;
cmd.CommandText = "INSERT INTO tbl ([val], [desc]) OUTPUT INSERTED.tbl_id VALUES (@val, @desc); "; cmd.Parameters.AddWithValue("@val", AccountSession.Current.UserId); cmd.Parameters.AddWithValue("@desc", Desc); retVal.id = cmd.ExecuteScalar().ToString();