Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP and Access Database

Posted on 1999-01-22
9
Medium Priority
?
156 Views
Last Modified: 2013-12-25
I have created a simple database, lets call it Members, and a form page using asp. I open a connection to the DSN and Then Open the recordset. After which I try to use the AddNew method and Update Method to add the data to the database. Does not Work. Can some please show me a working example.
0
Comment
Question by:vmorales
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 2

Expert Comment

by:jedimike
ID: 1859130
here's what I do....reference the recordset by name....

<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub addnew_onclick()
      News.addRecord
End Sub

Sub del_onclick()
      News.deleteRecord
      News.requery
      News.moveFirst
End Sub

Sub updateRec_onclick()
      News.updateRecord
      News.requery
      News.moveFirst
End Sub
</SCRIPT>
0
 

Author Comment

by:vmorales
ID: 1859131
Jedimike,
Forgive me, put I am far from being a programmer "of any type". I am trying to overcome these limitations, therefore I must ask you to provide a more indepth example. If you do not feel that this is worth only 50 points, I will be happy to increase.
0
 
LVL 10

Expert Comment

by:MasseyM
ID: 1859132
Sure:

Here is how you would add the items to a database called Members:
Table called "Members"
Fields called:
"Name","Address","Phone"

On your ASP page, you have input boxes called "name", "address", and "phone".

<%
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.open "Your_DSN","",""  'Your DSN may be "Members"
    sql = "SELECT * FROM Members
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open sql, Conn, 3, 3
%>

<%
RS.AddNew
RS("Name") = request("name")
RS("Address") = request("address")
RS("Phone") = request("phone")
RS.Update
%>

<%
RS.Close
Set RS = nothing
Conn.Close
Set Conn = nothing
%>

Obviously, you must check for errors in their entries..  But, this is how you add a record to a database.

0
Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

 

Author Comment

by:vmorales
ID: 1859133
MasseyM,

Thanks, I actually got an answer from a previous question someone else had asked, as a matter of fact, you answered that question for that person. I will be happy to give you the points for this, but may I ask what is the reason behind the following:
I am asking about what's inside the brackets.
    Conn.open "Your_DSN"[,"",""]  'Your DSN may be "Members"
    RS.Open sql, Conn,[ 3, 3 ]
thank you
0
 

Author Comment

by:vmorales
ID: 1859134
See previous comment.
0
 

Author Comment

by:vmorales
ID: 1859135
See previous comment.
0
 
LVL 6

Expert Comment

by:PBall
ID: 1859136
[ ] usually means optional, not required :)

0
 
LVL 6

Expert Comment

by:PBall
ID: 1859137
oh yeah, that also mean if you don't need it, don't put it in hehe.

in most cases, conn.open "DSN Name here" should do just fine with unprotected Access tables.
0
 
LVL 10

Accepted Solution

by:
MasseyM earned 150 total points
ID: 1859138
the first "" is for the username while the second "" is for password.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This video teaches users how to migrate an existing Wordpress website to a new domain.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question