| | |
Populating the DataBase problem
Please support our ASP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Solved Threads: 0
Hello All,
I want to store data into MS Access database without using DSN (Data Source Name). For his I have done the coding:-
Using this coding I am unable to send data to database from the Form. And I also do not getting any error messages.
Anyone please help me to solve this problem.
Thanks
I want to store data into MS Access database without using DSN (Data Source Name). For his I have done the coding:-
ASP Syntax (Toggle Plain Text)
<% dim stud1 set stud1=server.createobject("adodb.connection") stud1.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("amitdatabase.mdb") %> <% dim stud2,stud3 set stud2=server.createobject("ADODB.Recordset") stud3 = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;" stud2.CursorType = 2 stud2.lockType = 2 stud1.open stud2,stud3 %> <% stud2.addnew stud2("firstname")=request.form("one") stud2("lastname")=request.form("two") stud2("email")=request.form("three") stud2("username")=request.form("four") stud2("password")=request.form("five") stud2.update %>
Using this coding I am unable to send data to database from the Form. And I also do not getting any error messages.
Anyone please help me to solve this problem.
Thanks
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
Try this, and I'll let you know where you made mistakes
ASP Syntax (Toggle Plain Text)
<% dim stud1, stud2, stud3 set stud1 = server.createobject("adodb.connection") '''You do not open the connection string, you need to set the provider: '''stud1.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & '''Server.MapPath("amitdatabase.mdb") stud1.Provider "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("amitdatabase.mdb") & ";" '''no need to close and reopen asp brackets. set stud2 = server.createobject("ADODB.Recordset") '''You don't have to put the table name infront of the column UNLESS you are using '''more than 1 table, so keep it simple! '''stud3 = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;" stud3 = "SELECT Name, Comments FROM tblComments" '''You may or may not need these two lines below, depending on what you play on doing '''with your database (reading, writing, deleting, paging, etc.) '''if you have problems after this, try removing the next two lines, or commenting them out. stud2.CursorType = 2 stud2.lockType = 2 '''Now would be the time to open the connection! stud1.Open '''You already opened stud1, now you need to open your recordset! '''stud1.open stud2,stud3 '''You open your recordset with the query (stud3), on the following connection (stud1) stud2.open stud3, stud1 '''no need to close and reopen asp brackets. stud2.addnew stud2("firstname")=request.form("one") stud2("lastname")=request.form("two") stud2("email")=request.form("three") stud2("username")=request.form("four") stud2("password")=request.form("five") stud2.update '''You should add a Requery to this, it redoes the update to ensure no columns were missed. '''if you have problems, remove requery statement. Sometimes it produces an error. stud2.requery '''Don't forget to close the connection, or you will have major problems! stud1.Close '''Set them to nothing stud1 = "" set stud1 = nothing stud2 = "" set stud2 = nothing %>
Last edited by SheSaidImaPregy; Jan 17th, 2008 at 10:25 am.
•
•
Join Date: Dec 2007
Posts: 16
Reputation:
Solved Threads: 1
No need to write all this
just copy paste following.
<% dim stud1
set stud1=server.createobject("adodb.connection")
stud1.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("amitdatabase.mdb")
%>
<% dim stud2,stud3
set stud2=server.createobject("ADODB.Recordset")
stud3 = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"
stud2.CursorType = 2
stud2.lockType = 2
'stud1.open stud2,stud3
stud2.open stud3,stud1
%>
<%
stud2.addnew
stud2("firstname")=request.form("one")
stud2("lastname")=request.form("two")
stud2("email")=request.form("three")
stud2("username")=request.form("four")
stud2("password")=request.form("five")
stud2.update
%>
just copy paste following.
<% dim stud1
set stud1=server.createobject("adodb.connection")
stud1.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("amitdatabase.mdb")
%>
<% dim stud2,stud3
set stud2=server.createobject("ADODB.Recordset")
stud3 = "SELECT tblComments.Name, tblComments.Comments FROM tblComments;"
stud2.CursorType = 2
stud2.lockType = 2
'stud1.open stud2,stud3
stud2.open stud3,stud1
%>
<%
stud2.addnew
stud2("firstname")=request.form("one")
stud2("lastname")=request.form("two")
stud2("email")=request.form("three")
stud2("username")=request.form("four")
stud2("password")=request.form("five")
stud2.update
%>
![]() |
Similar Threads
- VB > Access2000 Database Upgrade Path (Visual Basic 4 / 5 / 6)
- Problem with Composite Key in MS Access (MS Access and FileMaker Pro)
- populating a listbox from another listbox dynamically?? (ASP)
- DataGrid: Edit mode, the index of a dropdownlist does not start at the right Value (ASP.NET)
Other Threads in the ASP Forum
- Previous Thread: asp-sql connection
- Next Thread: SQL String question
| Thread Tools | Search this Thread |
Tag cloud for ASP
archive asp asp.net aspandmssqlserver2005 aspandmssqlserver2005connection aspconnection calendar changeable connection current database databaseconnection diagnostics dreamweaver excel fso html iis microsoft msmsql mssql2005 mssqlserver2005 mssqlserver2005andasp mssqlserverandasp opentextfile record searchbox selectoption server single specfic sqlserver sqlserverconnection toolkit web webserver windows7






