vmorales
asked on
ASP and Access Database
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.
ASKER
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.
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.
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 .Connectio n")
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.
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
Conn.open "Your_DSN","","" 'Your DSN may be "Members"
sql = "SELECT * FROM Members
Set RS = Server.CreateObject("ADODB
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.
ASKER
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
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
ASKER
See previous comment.
ASKER
See previous comment.
[ ] usually means optional, not required :)
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.
in most cases, conn.open "DSN Name here" should do just fine with unprotected Access tables.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<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>