Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 December 28th, 2007, 06:03 AM
Authorized User
 
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default Please help me

i have some problem about my page that writes by asp but update access.
i don't knows its where wrong is/
Please check for me my code.

listcategory.asp

  <%
          set rs=conn.execute("Select * from categories")
          while not rs.eof
         %>
                 <tr>
                   <th scope="row">&nbsp;</th>
                   <th scope="row"><%=rs("categoryname")%></th>
                   <th scope="row">
                   <a href="FormUpdateCategories.asp?Categoryid=<%=rs("C ategoryID")%>">Edit</a></th>
                    </tr>
             <%
             rs.movenext
             wend
             rs.close
%>
formupdatecategory.asp


 <%
   set rs=conn.execute("Select * from categories where CategoryID="+request.QueryString(("CategoryID")))
 %>

and then error is by Browser

Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/VINATECH/Adminsite/FormUpdateCategories.asp, line 3

 
Old January 3rd, 2008, 06:13 PM
Authorized User
 
Join Date: Dec 2007
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vanik.cz
Default

I preserve that CategoryID is some of number data types...

Try in formupdatecategory.asp

set rs=conn.execute("SELECT * FROM categories WHERE CategoryID="+request("CategoryID")+";"

if categoryid is number in other case you must enclose it to aphostrophes like this:

set rs=conn.execute("SELECT * FROM categories WHERE CategoryID='"+request("CategoryID")+"';"

Works it?

Other hints: Check spelling in column names in database;
ensure that value is given thru:

it is much better if you build up the string and after this you call it:
query="SELECT * FROM categories WHERE CategoryID="+request("CategoryID")+";"
set rs=conn.execute(query)

bacause you can write query before executing by the

response.write query

and debug much errors this simple way

If it is not work please post the computed SQL query when the script fails

JVV
 
Old January 3rd, 2008, 10:26 PM
Authorized User
 
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Thanks so much to your help
but i have another error when i update database
that error:
formupdateproduct.asp
<form action=CodeAdd.asp?Option=AddProducts&ProductID=<% =request("ProductID")%> method="post" name=form >
</form>


codeupdate.asp

if trim(request("Option"))="UpdateProducts" then
        productid = trim(request.form("productid"))
        '="SELECT * FROM products WHERE productid="+request("productid")+";"
         query="UPDATE products SET productid ='"&productid&"',productname='"&productname&"',pro ductdecription='"&productdescription&"',price='"&p rice&"',equipment ='"&Equipment&"',productorder ='"&productorder&"',productstatus ='"&productstatus&"',productimage ='"&productimage&"',producerid ='"&producerid&"',categoryid ='"&categoryid&"',type ='"&producttype&"',stock ='"&stock&"'WHERE productid ="+request.QueryString("productid")+";"
            set rs=conn.execute(query)
            'response.Write(query)
            Response.Redirect("ListProduct.asp")
            rs.Close
            Set rs=nothing
        end if
and it error:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10)
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
/Vinatech/Adminsite/codeupdate.asp, line 61
line 61:
query="UPDATE products SET productid ='"&productid&"',productname='"&productname&"',pro ductdecription='"&productdescription&"',price='"&p rice&"',equipment ='"&Equipment&"',productorder ='"&productorder&"',productstatus ='"&productstatus&"',productimage ='"&productimage&"',producerid ='"&producerid&"',categoryid ='"&categoryid&"',type ='"&producttype&"',stock ='"&stock&"'WHERE productid ="+request.QueryString("productid")+";"


 
Old January 3rd, 2008, 10:44 PM
Authorized User
 
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default

I very fun that you show me to do that
thanks.
i have completed it and it run


 
Old January 4th, 2008, 07:25 AM
Authorized User
 
Join Date: Dec 2007
Posts: 21
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via ICQ to vanik.cz
Default

You should try to add my validate function (see bellow) and use it for string values. The point - as you propably know - is that the string value you must enclose to apostrophes, but there is two exclusions: the empty string and the string that contains aphostrophe. As empty string you cannot use '' but Null operator and if the string contains apostrophe you must use double apostrophe. This can be done by the validate function. There are some examples:

response.write validate("")
null

response.write validate("hello")
'hello'

response.write validate("it's done")
'it''s done'

so the function

function validate(text)
if text="" then
validate="null"
else
for a=len(text) to 1 step -1
if mid(text,a,1)="'" then
if mid(text,a-1,1)<>"'" then
leva=left(text,a-1)
prava=right(text,len(text)-a+1)
text=leva+"'"+prava
end if
end if
next

validate="'"+text+"'"
end if
end function

maybe you can use replace function but Im not sure that ASP supports it, maybe it is in VB6 only

you must use it only for string and date values, numbers must be without apostophes...

JVV
 
Old January 10th, 2008, 01:55 AM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

This post kind of lost me but change:

='"&stock&"'WHERE productid ="+request.QueryString("productid")+";"

To:

='"&stock&"' WHERE productid = " & request.QueryString("productid") & ";"

NOTE - get rid of the + and puut a space before the W in WHERE

An observation - is the field productid a string or an integer? If its an interger remove the single quotes.

Wind is your friend
Matt
www.elitemarquees.com.au
 
Old January 10th, 2008, 04:53 AM
Authorized User
 
Join Date: Dec 2007
Posts: 59
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Thanks so much everybody to help me.
Have a good day
Regards
Hoang Phuc










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