Hi Every one !!!
I want to know how i need to capture a duplicate value in database..For example if user enters the same E-mail which already in the database, I want to give a javascript alert or else re-direct to another page and wants to tell that "This is already reserved ".
I m using Access 2007 and VS 2008
My idea was these duplicate values are passed to Exception part..then i can capture it..
but it does not work
OleDbConnection conn = new OleDbConnection();
OleDbCommand comm = new OleDbCommand();
conn.ConnectionString = @ " database/path.mdb " ;
try
{
conn.Open();
string sql = "Insert into x ( a,b,c ) values (a,b,c)";
comm = new OleDbCommand(sql, conn);
comm.ExecuteNonQuery();
Session["mov"] = a.ToString();
Session["Hall"] = b.ToString();
Response.Redirect("Ho.aspx");
}
catch (Exception ex)
{
// Response.Write(ex.ToString());
[B] Response.redirect("Errorpage.aspx");[/B]
}
finally
{
conn.Close();
}