i found some codes on other forums concerning the cancellation of insert in formview if the record already exists. but its giving me an error stating that there is an incorrect sysntax near =?.... can you please tell me what's wrong with this syntax..i will post below the codes.
TextBox Client = (TextBox)FormView1.FindControl("ClientNameTextBox0");
string ConnectionString = "Data Source=DDDWEB\\SQLEXPRESS;Initial Catalog=Database;Integrated Security=True";
SqlConnection oConn = new SqlConnection(ConnectionString);
string strSQL = "Select Count(Client) as TheCount FROM Client WHERE ClientName =? ";
SqlCommand cmd = new SqlCommand(strSQL, oConn);
cmd.Parameters.AddWithValue("", Client.Text);
oConn.Open();
int Result = (int)cmd.ExecuteScalar();
if (Result > 0)
{
e.Cancel = true;
Label Duplicate = (Label)FormView1.FindControl("lblDuplicate");
Duplicate.Text = "There is already an existing record.";
}
oConn.Close();
im using sqldata source and if you have any idea on how to cancel insertion if the record already exist please feel free to write your post here..thanks in advance..i badly nedd your help..