?
Solved

ASP and Access Database

Posted on 1999-01-22
9
Medium Priority
?
155 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
Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

 

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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 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