 |
Question: Help with asp and ms access database?
(Posted by: GAGAN on 2010-07-07 01:32:24)
I have made a registeration page which feeds the information to an access database. i need to find a way by which we can find a particular value in the database and carry out actions if it is present or not. The database is named form.mdb and has a table named users. It has three columns id, name, email, password I want to check the email field for the value. the asp code that writes to database is here: < % ' Declaring variables Dim name, email, password, data_source, con, sql_insert ' A Function to check if some field entered by user is empty Function ChkString(string) If string = " " Then string = " " ChkString = Replace(string, "' ", "'' ") End Function ' Receiving values from Form name = ChkString(UCASE(Request.Form( "name "))) email = ChkString(Request.Form( "email ")) password = ChkString(Request.Form( "password ")) data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & _ Server.MapPath( "form.mdb ") sql_insert = "insert into users ([name], [email], [password]) values (' " & _ name & "', ' " & email & "', ' " & password & "') " ' Creating Connection Object and opening the database Set con = Server.CreateObject( "ADODB.Connection ") con.Open data_source con.Execute sql_insert ' Done. Close the connection con.Close Set con = Nothing % > |