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 March 21st, 2004, 01:18 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default can't insert in db

When I try to insert stuff in my db, it fails... Can anyone tell me what I'm doing wrong?

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/cookbook/insert.asp, line 60

line 60 is -> rs.open "Recipe", db, adopenstatic, adlockoptimistic

****Recipe is the table that I'm trying to enter stuff in...

<form name="Add" method="post" action="insert.asp">
 <%
  if Request.Form("flag") <> "" then

' on error resume next

  Set db = Server.CreateObject("ADODB.Connection")
  db.open "Cookbook"

  Set rs = Server.CreateObject("ADODB.Recordset")
  rs.open "Recipe", db, adopenstatic, adlockoptimistic
  rs.addnew
   rs("R_name") = Request.Form("meal")
   rs("R_category") = Request.Form("category")
   rs("R_ingredients") = Request.Form("ingredients")
   rs("R_instructions") = Request.Form("instruct_str")
  rs.update


 
Old March 22nd, 2004, 05:19 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hello
try this
<%
Sub Application_OnStart
        Application("Cnn_ConnectionString") = "DSN=DSNNAME;DBQ=C:\Database\DATABASENAME.mdb;Driv erId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
        Application("Cnn_ConnectionTimeout") = 15
        Application("Cnn_CommandTimeout") = 30
        Application("Cnn_CursorLocation") = 3
        Application("Cnn_RuntimeUserName") = ""
        Application("Cnn_RuntimePassword") = ""
end sub
set cnn=Server.CreateObject("ADODB.connection")
cnn.Open Application("Cnn_connectionstring")
set Rs=server.CreateObject ("ADODB.Recordset")
sql="insert into tablename(R_name,R_category,R_ingredients,R_instru ctions)values('"&meal&"','"&category&"','"&ingredi ents&"','"&instruct_str&"')"
cnn.Execute(sql)
%>

surendran
(Anything is Possible)
 
Old March 23rd, 2004, 10:04 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why I try the code you provided, I get this error

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/cookbook/insert.asp, line 66

line 66 -> 'cnn.Open Application("Cnn_connectionstring")

[code]

Sub Application_OnStart
        Application("Cnn_ConnectionString") = "DSN=Cookbook;DBQ=C:\Inetpub\wwwroot\cookbook\cook book.mdb;DriverId=281;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
        Application("Cnn_ConnectionTimeout") = 15
        Application("Cnn_CommandTimeout") = 30
        Application("Cnn_CursorLocation") = 3
        Application("Cnn_RuntimeUserName") = ""
        Application("Cnn_RuntimePassword") = ""
end sub

%>

<script language="JavaScript">
<!--
function SetInfo()
{
    document.Add.flag.value="1";
    document.Add.submit();
}
-->
</script>
</head>

<body>
<form name="Add" method="post" action="insert.asp">
    <%
        if Request.Form("flag") <> "" then

' on error resume next
set cnn=Server.CreateObject("ADODB.connection")
cnn.Open Application("Cnn_connectionstring")
'cnn.open "Cookbook"
set Rs=server.CreateObject ("ADODB.Recordset")
sql="insert into Recipe(R_name,R_category,R_ingredients,R_instructi ons)values('"&meal&"','"&category&"','"&ingredient s&"','"&instruct_str&"')"
cnn.Execute(sql)

I tried it without using the driver line, and go back to the dns connection


Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/cookbook/insert.asp, line 70

line 70 -> cnn.Execute(sql)

set cnn=Server.CreateObject("ADODB.connection")
'cnn.Open Application("Cnn_connectionstring")
cnn.open "Cookbook"
set Rs=server.CreateObject ("ADODB.Recordset")
sql="insert into Recipe(R_name,R_category,R_ingredients,R_instructi ons)values('"&meal&"','"&category&"','"&ingredient s&"','"&instruct_str&"')"
cnn.Execute(sql)

Can anyone tell my, why I'm unable to insert to a db???

 
Old March 23rd, 2004, 10:44 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Go to the search page and look up "updateable query". There are pages of threads discussing this problem.
 
Old March 26th, 2004, 12:30 PM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to norpcom Send a message via Yahoo to norpcom
Default

I am having the exact same problem. I have looked everwhere and this is the only place that mentions this issue. It's not just access databases that have this problem either, I tried to do this on MS SQL 7.0 and with the standard SQL ODBC drive and got the exact same error message. I have tried all the different LOCK types and all the different CursorTypes. This has to be a bug in the ASP language, because similar code in standard VB and C++ works fine.

Please help.

Adam

 
Old March 26th, 2004, 09:34 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you add a declaration for the various ADO constants (LockType etc)?

If you never included them, you'll end up with undeclared variables, defaulting to 0. In that case, trying all lock types wouldn't really make a difference. It would also explain the errors you're getting....

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 27th, 2004, 03:11 AM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi i am having same problems also, heres my code doe sanyone have a clue?

<%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work

If Session("UserLoggedIn") <> "true" Then
    Response.Redirect("default.asp")
End If


if Session("logId")<>1 then
   Response.write "<b>You are not Authorized to Manage Users</b>"
else
%>
<center>

<h1>Enter New Subject</h1><br><br>

<%
a=0
for each item in request.form
   if request.form(item)="" then
    a=a+1
   end if
next

if a>0 then
  response.write "Please fill all fields"

%>
<h3> <A href="javascript:history.back()"
            onclick="history.back();return false">Go Back</A> </h3>
<%


else


Dim con, sConnString
        dim i, rs,rs2


    set con=Server.CreateObject("ADODB.Connection")
         set rs=Server.CreateObject("ADODB.Recordset")
         set rs2=Server.CreateObject("ADODB.Recordset")
        sConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
        "DBQ=" & Server.MapPath("../mmu.mdb") & ";"

    con.Open(sConnString)

       rs.open "select * from tblTimeTable where lcase(subjid)='" & lcase(trim(request.form("txtSubj"))) & "'",con,3,3


    if rs.recordcount>0 then
       response.write "<b>Subject Already exist, please try to modify the existing subject</b>"
%>
<h3> <A href="javascript:history.back()"
            onclick="history.back();return false">Go Back</A> </h3>
<%
    else

      rs2.open "select * from tblTimeTable",con,3,3
      rs2.addnew
      rs2("subjid")=trim(request.form("txtSubj"))
      rs2("mon")=trim(request.form("txtMon"))
        rs2("tue")=trim(request.form("txttue"))
        rs2("wed")=trim(request.form("txtWed"))
        rs2("thur")=trim(request.form("txtThu"))
        rs2("fri")=trim(request.form("txtFri"))
        rs2("sat")=trim(request.form("txtSat"))
        rs2("sun")=trim(request.form("txtSun"))



      rs2.update
      response.write "<b>New Subject Info entered Successfully</b>"
      rs2.close
      set rs2=nothing
    end if


    rs.close
    set rs=nothing
    con.close
    set con=nothing


end if
end if
%>


<br><br>
<a href=admin.asp>Admin Home</a></center



heres my error message

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
/admin/ttblenterok.asp, line 74


BUT IV MADE SURE THAT THERE ARE NO LOCKS ON IT. PLEASEEEE HELP.

 
Old March 27th, 2004, 03:58 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Does the IUSR_MachineName account have sufficient permissions to alter the database? Check the properties for the folder where your database resides in and look at the Security settings. Make sure the IUSR_MachineName has change permissions on that folder, not only to the .mdb file.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old March 27th, 2004, 04:37 PM
Registered User
 
Join Date: Mar 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I USR_machineName?
where would i find it?
do i need to chaneg any of my code to conform with it?

sorry its just that i am quite new to this.
thanks


 
Old March 28th, 2004, 04:58 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Please check out this FAQ: http://Imar.Spaanjaars.Com/QuickDocID.aspx?QUICKDOC=263

It deals with some causes of 80004005 errors, and explains how to give the IUSR account sufficient permissions to your database.

HtH,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Attempting to Insert Value into DB Query Snuffles ASP.NET 2.0 Basics 2 April 2nd, 2007 08:17 AM
Insert Variable Value into DB Deano252 ASP.NET 2.0 Basics 1 June 24th, 2006 03:21 AM
Insert into db error keyvanjan Classic ASP Databases 1 December 5th, 2005 07:30 AM
insert into db keyvanjan Classic ASP Databases 1 May 9th, 2005 11:50 PM
Unable to INSERT INTO db nvillare Classic ASP Databases 6 August 26th, 2003 10:29 AM





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