Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 20th, 2005, 05:10 PM
Authorized User
 
Join Date: Jan 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding record to database?

Is there an error in this script that will not allow to work?


Code:
<%@Language = "VbScript"%>

<%
dim objConn,objRec 
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Provider="Microsoft.Jet.OLEDB.4.0"
objConn.Open "\\lou1-web01\robohelp\shpsmate\shpsmate v3\hot topics.mdb"
 Set objRec = Server.CreateObject ("ADODB.Recordset")   
  objRec.Open "hottopic", bookdb, adOpenStatic, adLockOptimistic, adCmdTable
%>
<%
  objRec.AddNew
  ObjRec("Name") = "SOG"
  objRec("Control") = "10029"
  objRec.Update

%>
I get page cannot be displayed but Im using the full web address



Thanks


 
Old January 20th, 2005, 05:36 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this..
**************
<%@Language = "VbScript"%>

<%
dim objConn,objRec
set objConn=Server.CreateObject("ADODB.Connection")

Dim strConn
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\somepath\mydb.mdb;" 'change the db path

objConn.Open strConn


Set objRec = Server.CreateObject ("ADODB.Recordset")
objRec.Open "hottopic", objConn, adOpenStatic, adLockOptimistic, adCmdTable
%>
<%
objRec.AddNew
ObjRec("Name") = "SOG"
objRec("Control") = "10029"
objRec.Update

%>
****
use server.mappath() in your connection string
use SQL insert into statement instead of using ADO to insert a record

last suggestion.. get a book.. Beginning ASP databases neat stuff..
 
Old January 20th, 2005, 05:43 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you want to know what error you are receiving

If you are using Internet Explorer then
Go to Tools-->Internet Options -->Advanced--> uncheck show friendly HTTP error messages
 
Old January 20th, 2005, 05:46 PM
Authorized User
 
Join Date: Jan 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the advice and the quick response I am able to get my page to display but it shows this error
Provider error '80020005'

Type mismatch.

/robohelp/shpsmate/shpsmate v3/Hotadd.asp, line 18

Here is the adjusted code
Code:
<html>
<head>
<p>Add You're Stuff</P>
</Head>
<Body>
<Form action="hotadd.asp" method="post">
<input type="text" name="date">
<input type="text" name="Control">
<input type="submit" name="sub">
</body>
</HTML>
<%@Language = "VbScript"%>

<%
strConn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ="&Server.mapPath("Hot Topics.mdb")

Set ObjRs=Server.CreateObject("ADODB.Recordset")
ObjRs.Open "Hottopic", objConn, strConn, adCmdTable
ObjRs.AddNew
'ObjRs("ID")=Request.form("ID")
ObjRs("Date")=Request.form("Date")
ObjRs("Control")=Request.form("Control")
'ObjRs("Name")=Request.form("Name")
'ObjRs("Comments")=Request.form("Comments")
'ObjRs("Contact")=Request.form("Contact")
ObjRs.Update
ObjRs.Close
Set ObjRs=Nothing

Response.write "<center><b>Record Added!</b></center>"
%>

 
Old January 20th, 2005, 06:07 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

change your code as follows
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Hot Topics.mdb")

ObjRs.Open "Hottopic", objConn, adOpenKeySet,adLockOptimistic,adCmdTable

 
Old January 20th, 2005, 06:27 PM
Authorized User
 
Join Date: Jan 2005
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/robohelp/shpsmate/shpsmate v3/Hotadd.asp, line 18







Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding New Record to Access Database Using VB.NET TechHelp ASP.NET 1.0 and 1.1 Basics 1 September 13th, 2006 03:19 AM
Adding or updating record using VBA egivler Access VBA 0 August 31st, 2004 11:06 AM
Adding a new record to a dataset Louisa VB.NET 2002/2003 Basics 1 January 14th, 2004 05:33 PM
trouble adding new record TnTandyO Classic ASP Databases 1 November 4th, 2003 02:20 PM
Adding a record using a form cailos Access 2 October 12th, 2003 11:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.