How do I write an error-routine to check the results of an insert to an access database?
If the Insert was good continue on else post a message back
to the user stating there was an error.
The code listed below currently does the insert. Could someone please add the Error-routine to this code based
on the criteria I stated above?
Secondly. I would also like to programatically supply
a password to the code listed below. I already have
placed a password on the gradapp.mdb file. It is 1220bw,
all lowercase.
Thanks for your time and cooperation in this.
Here's the code:
Thanks Bill Ward b.ward@vanderbilt.edu
'build insert statement
Dim sInsertCommand
sInsertCommand = "INSERT INTO GradApp (name, ssn, housing_plans," & _
" custody, custody_ages, custody_cost, summer_2002, fall_2002," & _
" spring_2003, summer_2003, plan_program) VALUES ('" & sName & "', '" & _
sSSN & "', '" & sHousingPlans & "', '" & sCustody & "', '" & sCustodyAges & "', '" & _
sCustodyCost & "', '" & sSummer2002 & "', '" & sFall2002 & "', '" & sSpring2003 & "', '" & _
sSummer2003 & "', '" & sPlanProgram & "')"
'Response.Write sInsertCommand
'create and open connection object
Dim sConnectString
sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("gradapp.mdb"
& ";Persist Security Info=False"
Dim cn
Set cn = Server.CreateObject("ADODB.Connection"
cn.Open sConnectString
'create and execute command
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command"
cmd.ActiveConnection = cn
cmd.CommandText = sInsertCommand
cmd.Execute
'close connection and destroy objects
cn.Close
Set cmd = Nothing
Set cn = Nothing
If the Insert was good continue on else post a message back
to the user stating there was an error.
The code listed below currently does the insert. Could someone please add the Error-routine to this code based
on the criteria I stated above?
Secondly. I would also like to programatically supply
a password to the code listed below. I already have
placed a password on the gradapp.mdb file. It is 1220bw,
all lowercase.
Thanks for your time and cooperation in this.
Here's the code:
Thanks Bill Ward b.ward@vanderbilt.edu
'build insert statement
Dim sInsertCommand
sInsertCommand = "INSERT INTO GradApp (name, ssn, housing_plans," & _
" custody, custody_ages, custody_cost, summer_2002, fall_2002," & _
" spring_2003, summer_2003, plan_program) VALUES ('" & sName & "', '" & _
sSSN & "', '" & sHousingPlans & "', '" & sCustody & "', '" & sCustodyAges & "', '" & _
sCustodyCost & "', '" & sSummer2002 & "', '" & sFall2002 & "', '" & sSpring2003 & "', '" & _
sSummer2003 & "', '" & sPlanProgram & "')"
'Response.Write sInsertCommand
'create and open connection object
Dim sConnectString
sConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("gradapp.mdb"
Dim cn
Set cn = Server.CreateObject("ADODB.Connection"
cn.Open sConnectString
'create and execute command
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command"
cmd.ActiveConnection = cn
cmd.CommandText = sInsertCommand
cmd.Execute
'close connection and destroy objects
cn.Close
Set cmd = Nothing
Set cn = Nothing