Solved

ASP and Access Database

Posted on 1999-01-22
9
144 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
  • 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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 50 total points
ID: 1859138
the first "" is for the username while the second "" is for password.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
erros on link  checking 2 42
Problem to go to Web page 2 51
Do we need servers??? 5 131
remove border from element 5 10
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now