Solved

ASP and Access Database

Posted on 1999-01-22
9
150 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

756 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