Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Inserting Records in an Access Database
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Inserting Records in an Access Database

 Post Reply Post Reply
Author
Lyrik View Drop Down
Newbie
Newbie


Joined: 22 August 2003
Location: United States
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote Lyrik Quote  Post ReplyReply Direct Link To This Post Topic: Inserting Records in an Access Database
    Posted: 24 August 2003 at 3:38pm

Someone please help! I've been working on a project for work for sometime now and still can't get it to function properly. I created this form which calls an access database to gather request information from users. Using asp,this form should lookup fields in the database, populate the form, sent out an email to users when submitted, and then insert their requests in an issues table when done. Everything works great accept for the insert part. I honesty don't believe my code is the culpret, I'm assuming it has something to do with setting permissions in IIS. I am currently running Windows XP and IIS 5.0. For testing purposes, I am using my labtop as the webserver. All files are being stored locally in my wwwroot folder. Below is the code for my form and the asp which is called on submittion. Any help on this issue would be greatly appreciate. Please let me know if further explanation is needed. Thanks in advance.

Note: Using DSN-Less Connection method. This file (db) is used to specify the path:

<%
'-- Include file for database -- '
Const DatabasePath = "C:\Inetpub\wwwroot\Pid\IS_Issue_DB.mdb"
%>

Form Code:

<%@ Language=VBScript %>

<% Response.Buffer = Test %>
<!-- #include file="db.asp" -->

<%
Dim oConn1
Dim oRs1
Dim strSQL

 myDSN="Driver={Microsoft Access Driver (*.mdb)};;Dbq=" & DatabasePath & ";"

 Set oConn1 = Server.CreateObject("ADODB.Connection")
 Set oRs1 = Server.CreateObject("ADODB.Recordset")
    oConn1.Open myDSN

strSQL = "SELECT * "
strSQL = strSQL & "FROM Users ORDER BY Name"
oRs1.Open strSQL, oConn1

userid = userid & "<OPTION SELECTED VALUE=""""></OPTION>"
WHILE NOT oRs1.EOF
 userid = userid & "<OPTION VALUE="""& oRs1.Fields("OperatorID") & """>" & oRs1.Fields("Name") & "</OPTION>"
 'userid = userid & "<option>" & oRs("OperatorID") & "</option>"
 oRs1.MoveNext
WEND

oRs1.Close
SET oRS1 = Nothing
oConn1.Close
SET oConn1 = Nothing
%>

<%
 myDSN="Driver={Microsoft Access Driver (*.mdb)};;Dbq=" & DatabasePath & ";"

 Set oConn1 = Server.CreateObject("ADODB.Connection")
 Set oRs1 = Server.CreateObject("ADODB.Recordset")
    oConn1.Open myDSN

strSQL = "SELECT * "
strSQL = strSQL & "FROM Location ORDER BY Office"
oRs1.Open strSQL, oConn1

location = location & "<OPTION SELECTED VALUE=""""></OPTION>"
WHILE NOT oRs1.EOF
 location = location & "<OPTION VALUE="""& oRs1.Fields("id") & """>" & oRs1.Fields("Office") & "</OPTION>"
 'userid = userid & "<option>" & oRs("OperatorID") & "</option>"
 oRs1.MoveNext
WEND

oRs1.Close
SET oRS1 = Nothing
oConn1.Close
SET oConn1 = Nothing
%>

<%
 myDSN="Driver={Microsoft Access Driver (*.mdb)};;Dbq=" & DatabasePath & ";"

 Set oConn1 = Server.CreateObject("ADODB.Connection")
 Set oRs1 = Server.CreateObject("ADODB.Recordset")
    oConn1.Open myDSN

strSQL = "SELECT * "
strSQL = strSQL & "FROM DB_Branch ORDER BY Branch"
oRs1.Open strSQL, oConn1

branch = branch & "<OPTION SELECTED VALUE=""""></OPTION>"
WHILE NOT oRs1.EOF
 branch = branch & "<option value=" & oRs1("ID") & ">" & oRs1("Branch") & "</option>"
 oRs1.MoveNext
WEND

oRs1.Close
SET oRS1 = Nothing
oConn1.Close
SET oConn1 = Nothing
%>

<%
 myDSN="Driver={Microsoft Access Driver (*.mdb)};;Dbq=" & DatabasePath & ";"

 Set oConn1 = Server.CreateObject("ADODB.Connection")
 Set oRs1 = Server.CreateObject("ADODB.Recordset")
    oConn1.Open myDSN

strSQL = "SELECT * "
strSQL = strSQL & "FROM Category ORDER BY Category"
oRs1.Open strSQL, oConn1

category = category & "<OPTION SELECTED VALUE=""""></OPTION>"
WHILE NOT oRs1.EOF
 category = category & "<option value=" & oRs1("ID") & ">" & oRs1("Category") & "</option>"
 oRs1.MoveNext
WEND

oRs1.Close
SET oRS1 = Nothing
oConn1.Close
SET oConn1 = Nothing
%>

<%
 myDSN="Driver={Microsoft Access Driver (*.mdb)};;Dbq=" & DatabasePath & ";"

 Set oConn1 = Server.CreateObject("ADODB.Connection")
 Set oRs1 = Server.CreateObject("ADODB.Recordset")
    oConn1.Open myDSN
 
strSQL = "SELECT * "
strSQL = strSQL & "FROM Severity ORDER BY Severity_Desc"
oRs1.Open strSQL, oConn1

severity = severity & "<OPTION SELECTED VALUE=""""></OPTION>"
WHILE NOT oRs1.EOF
 severity = severity & "<option value=" & oRs1("Level") & ">" & oRs1("Severity_Desc") & "</option>"
 oRs1.MoveNext
WEND

oRs1.Close
SET oRS1 = Nothing
oConn1.Close
SET oConn1 = Nothing
%>

<html>
  <head>
 <title>On-Line Help Desk</title>
 <meta name="Microsoft Theme" content="canvas 011">
 
  <!-- Load external JavaScript -->
<script language="JavaScript" src="cookies.js">
</script>
<!-- End load external JavaScript -->
 
<script language="JavaScript">
<!--
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
 //d10=p.indexOf('(')
 pp=p;
 d4=p.indexOf('(')
 d5=p.indexOf(')')
 if(d4==-1){
  pp="("+pp;
 }
 if(d5==-1){
  pp=pp+")";
 }
 //pp="("+pp+")";
 document.form2.Phone.value="";
 document.form2.Phone.value=pp;
}
if(p.length>3){
 d1=p.indexOf('(')
 d2=p.indexOf(')')
 if (d2==-1){
  l30=p.length;
  p30=p.substring(0,4);
  //alert(p30);
  p30=p30+")"
  p31=p.substring(4,l30);
  pp=p30+p31;
  //alert(p31);
  document.form2.Phone.value="";
  document.form2.Phone.value=pp;
 }
 }
if(p.length>5){
 p11=p.substring(d1+1,d2);
 if(p11.length>3){
 p12=p11;
 l12=p12.length;
 l15=p.length
 //l12=l12-3
 p13=p11.substring(0,3);
 p14=p11.substring(3,l12);
 p15=p.substring(d2+1,l15);
 document.form2.Phone.value="";
 pp="("+p13+")"+p14+p15;
 document.form2.Phone.value=pp;
 //obj1.value="";
 //obj1.value=pp;
 }
 l16=p.length;
 p16=p.substring(d2+1,l16);
 l17=p16.length;
 if(l17>3&&p16.indexOf('-')==-1){
  p17=p.substring(d2+1,d2+4);
  p18=p.substring(d2+4,l16);
  p19=p.substring(0,d2+1);
  //alert(p19);
 pp=p19+p17+"-"+p18;
 document.form2.Phone.value="";
 document.form2.Phone.value=pp;
 //obj1.value="";
 //obj1.value=pp;
 }
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
n=m.name;
//p1=document.forms[0].elements[n]
p1=m
ValidatePhone()
}
function testphone(obj1){
p=obj1.value
//alert(p)
p=p.replace("(","")
p=p.replace(")","")
p=p.replace("-","")
p=p.replace("-","")
//alert(isNaN(p))
if (isNaN(p)==true){
alert("Check phone");
return false;
}
}

// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minY

Back to Top
peterm View Drop Down
Newbie
Newbie


Joined: 24 November 2002
Location: United Kingdom
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote peterm Quote  Post ReplyReply Direct Link To This Post Posted: 05 September 2003 at 4:53am

Quote Everything works great accept for the insert part.  works great accept for the insert part.

What is the error you are getting exactly?

If you know its failing on the insert, then after you insert the record (oConn1.Execute(sSQL)) put the following lines:

If Err <> 0 Then
  Response.Write Err.Description
  Response.End
End If

This will tell you what the problem is...

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.