Hi Every one !!!
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 " ;
string sql = "Insert into x ( a,b,c ) values (a,b,c)";
comm = new OleDbCommand(sql, conn);
Session["mov"] = a.ToString();
Session["Hall"] = b.ToString();
catch (Exception ex)
Well , that means when some one enters email ( for an example )...I have to write a code which can check whether its already in the database....??
I m not sure how to do it :(
But hopefully due to Your guidance i got an idea how should i implement it..Thanks...
When user inserting data and Press the submit button..Entered values should have to go to the database..and have to search the database..If it found same data..It should display the message...
Am i right ???
also if you can better direct me , how implement that Searching part..
Thanks For your help
There are quite a few ways to go about accomplishing this... First thing though, you do not want to use exceptions in that manner. Secondly, why not use the built in asp.net membership provider rather than creating one in access?
If you insist though your code would be something like...
MsgBox("Your E-mail Address Has Been Subscribed !")
Catch ex As Exception
MsgBox("Your E-mail Address Has Been Already Subscribed Before !")
you can also use "IF NOT EXISTS" so your code would look something like
InsertCommand="IF NOT EXISTS(SELECT [username] FROM [usertable] WHERE [username] = ?) BEGIN INSERT INTO [usertable] ([username]) VALUES (?)"
Hope that helps - please mark as solved if it does.
by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).