Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - web form entry to access database w/asp
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

web form entry to access database w/asp

 Post Reply Post Reply Page  <123>
Author
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2003 at 4:35pm
if it still doesn't work then can you give me the name of the database so i can use a dsn-less connection.
Back to Top
swatson View Drop Down
Newbie
Newbie


Joined: 11 April 2003
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote swatson Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2003 at 4:42pm

Hi Paul - I had actually changed "rsAddFacility.update" to "rs.update". The record still wasn't added to the database.  I have the html file, the asp file and the database in a MyWeb folder in wwwroot.  The name of the database is mmugprofiles.mdb

Maybe I am not running files properly? To run them, I have been opening my browser (Explorer), File, Open-scroll to the html file.  Then, I entered the data in the web form and hit the submit button.  My browser returns with the asp code.  Is there something else that I should be doing?

thank you!

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2003 at 5:03pm
alright, are you running a web server with iis/pws installed? If so can you send me the name of the operating system. Generally you would type this into the-- http://localhost/thenameofyourhtmlfile your computer needs to have iis or pws installed and running for your computer to run any asp programming
Back to Top
swatson View Drop Down
Newbie
Newbie


Joined: 11 April 2003
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote swatson Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2003 at 5:10pm

Hi Paul - Yes, I'm running IIS with Windows 2000.  I'm now running the files from http://localhost/MyWeb/form.html

I'm now trying this cleaned-up code for the asp file:

<html>
<head>
<title>Adding data to database</title>
</head>
<body>

Adding data to database...


<%
'Dimension variables

Dim conn
Dim rs
Dim strSQL

'Create an ADO connection object
Set conn=Server.CreateObject("ADODB.Connection")

'Set an active connection to the Connection object using a DSN connection
conn.Open "DSN=profiles"

'Create an ADO recordset object
Set rs=Server.CreateObject("ADODB.Recordset")

strSQL="SELECT* FROM Facility;"

'Open the recordset with the SQL query
rs.Open strSQL, conn

'rs.CursorType=2
'Set the cursor type we are using so we can navigate through the recordset

'rsDatabase.LockType=3
'Set the lock type so that the record is locked by ADO when it is updated

rs.AddNew
'Tell the recordset we are adding a new record to it

rs.Fields("Facility_id")=Request.Form("Facility_id")
rs.Fields("Facility_name")=Request.Form("Facility_name")
rs.Fields("Facility_description")=Request.Form("Facility_description")
rs.Fields("Street_address1")=Request.Form("Street_address1")
rs.Fields("Street_address2")=Request.Form("Street_address2")
rs.Fields("City")=Request.Form("City")
rs.Fields("State")=Request.Form("State")
rs.Fields("Zipcode")=Request.Form("Zipcode")
rs.Fields("Website")=Request.Form("Website")
rs.Fields("Image")=Request.Form("Image")
'Add a new record to the dataset

rs.Update
'Write the updated recordset to the database

'Reset server objects
rs.Close
Set rs=Nothing
Set conn=Nothing

Response.Redirect "display_profile_db.asp"
'To display all the records in the database, including the new ones

%>

</body>
</html> 

But, when I run it -- Line 37 rs.AddNew gives me this error:

Error Type:
ADODB.Recordset (0x800A0CB3)
Object or provider is not capable of performing requested operation.
/MyWeb/add_to_db3.asp, line 37

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2003 at 5:46pm

i had some problems with rs.addnew too. THe following is an sql code for adding a new record. It should work.
Your going to have to assign each of the Request.Forms to a seperate variable. the first thing listed after the insert into facility statement in the parenthesis matches up with the first thing after the values statement and so on. Also, make sure that the insert into statment is on one line and the values statement is on another. The bbs might word wrap. I'm a little rusty on sql but it should work according to my reference book. Replace the following code where the rs.addnew and company whould go.

INSERT INTO Facility (Facility_ID, Facility_Name, Facility_Description, Street_address1, street_address2, city, state, zipcode, website, image)
VALUES (Facility_ID, Facility_Name, Facility_Description, Street_address1, street_address2, city, state, zipcode, website, image)

 

 

Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 11 April 2003 at 5:49pm

also, if that doesn't work. (Again!) then make sure that you have write permissions for your database or it cant write to your database

 

Back to Top
bassy View Drop Down
Newbie
Newbie


Joined: 11 April 2003
Location: Netherlands
Status: Offline
Points: 3
Post Options Post Options   Thanks (0) Thanks(0)   Quote bassy Quote  Post ReplyReply Direct Link To This Post Posted: 13 April 2003 at 9:11am

Hi swatson,

I had exactly the same probleme as you but I've found the following:

file (form.ASP) instead of  file (form.html). It 's very misleading.

So you have to run from IIS the form file with the extension .ASP dont use the extension html.

And it will work

good luck, let know if it works

 

Back to Top
swatson View Drop Down
Newbie
Newbie


Joined: 11 April 2003
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote swatson Quote  Post ReplyReply Direct Link To This Post Posted: 14 April 2003 at 1:01pm

Hi All -

Thanks to pmormr for all the help and to Bassy for the .asp extension tip.  The .asp extension on the form file helped - now my form seems to actually be calling and implementing the add_to_database asp file. 

However, I wasn't able to get the sql statement approach to work since the statement continued on more than one line and even breaking it into two parts didn't work.

I'm trying the connection object approach (using sql_insert as a dim variable). But, I'm getting the following error:

  • Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 10.
    /MyWeb/add_to_db6.asp, line 74
  • Can anyone help with this?  I seem to have 10 parameters -- this is all the form fields...
  • Here is my add to database asp file (add_to_db6.asp):
    <html>
    <head>
    <title>Adding data to database</title>
    </head>
    <body>
    Adding data to database...(to test that form.asp is calling this file)
    <%

    'Dimension variables
    Dim conn
    Dim sql_insert

    Dim Facility_id
    Dim Facility_name
    Dim Facility_description
    Dim Street_address1
    Dim Street_address2
    Dim City 
    Dim State
    Dim Zipcode
    Dim Website
    Dim Image

    sql_insert="insert into Facility (Facility_id, Facility_name, Facility_description, Street_address1, Street_address2, City, State, Zipcode, Website, Image) VALUES" & _
     "(Facility_id, Facility_name, Facility_description, Street_address1, Street_address2, City, State, Zipcode, Website, Image);"

    'Create an ADO connection object
    Set conn=Server.CreateObject("ADODB.Connection")

    'Set an active connection to the Connection object using a DSN connection
    conn.Open "DSN=profiles"

    'Set up variables to receive the information from the form
    Facility_id=Request.Form("Facility_id")
    Facility_name=Request.Form("Facility_name")
    Facility_description=Request.Form("Facility_description")
    Street_address1=Request.Form("Street_address1")
    Street_address2=Request.Form("Street_address2")
    City=Request.Form("City")
    State=Request.Form("State")
    Zipcode=Request.Form("Zipcode")
    Website=Request.Form("Website")
    Image=Request.Form("Image")

    'Write back form submittal to user - to confirm that the form entries are being read. This works.
    Response.Write("<br />")
    Response.Write("You submitted the following:")
    Response.Write("<br />")
    Response.Write(Facility_id)
    Response.Write("<br />")
    Response.Write(Facility_name)
    Response.Write("<br />")
    Response.Write(Facility_description)
    Response.Write("<br />")
    Response.Write(Street_address1)
    Response.Write("<br />")
    Response.Write(Street_address2)
    Response.Write("<br />")
    Response.Write(City)
    Response.Write("<br />")
    Response.Write(State)
    Response.Write("<br />")
    Response.Write(Zipcode)
    Response.Write("<br />")
    Response.Write(Website)
    Response.Write("<br />")
    Response.Write(Image)
    Response.Write("<br />")

    conn.Execute sql_insert
    'somehow this is not inserting the form submittals to the database

    'Reset server objects
    conn.Close
    Set conn=Nothing

    Response.Redirect "display_profile_db.asp"
    'To display all the records in the database, including the new ones

    %>
    </body>
    </html> 

    And, here is the form.asp file:
    <html>
    <head>
    <title>Profile Data Entry Form</title>
    </head>

    <Body bgcolor="#0099CC" text="white" link="#0000FF" alink="#FF0000" vlink="#663399">
    <font face = "Georgia">
    <H1 Align="center">Profile Data Entry Form</H1>
    </font>

    <form name="Form" method="post" action="add_to_db6.asp">

    Facility_id
    <input type = "text" name="Facility_id" size = 10>
    <br>
    Facility_name
    <input type="text" name="Facility_name" size = 100>
    <br>
    Facility_description
    <input type="text" name="Facility_description" size = 1000>
    <br>
    Street Address1
    <input type="text" name="Street_address1" size = 100>
    <br>
    Street_Address2
    <input type="text" name="Street_address2" size = 100>
    City
    <input type="text" name="City" size = 50>
    State
    <input type="text" name="State" size = 10>
    <br>
    Zipcode
    <input type="text" name="Zipcode" size = 12>
    <br>
    Website
    <input type="text" name="Website" size = 50>
    <br>
    Image
    <input type="text" name="Image" size = 50>
    <br>

    <p><input type="Submit" name="Submit" value="SUBMIT"></p>

    </form>
    </body>
    </html>

    Back to Top
     Post Reply Post Reply Page  <123>

    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.