Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 28th, 2007, 06:03 AM
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
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

Reply With Quote
  #2 (permalink)  
Old January 3rd, 2008, 06:13 PM
Authorized User
 
Join Date: Dec 2007
Location: Liberec, , Czech Republic.
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
Reply With Quote
  #3 (permalink)  
Old January 3rd, 2008, 10:26 PM
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
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")+";"


Reply With Quote
  #4 (permalink)  
Old January 3rd, 2008, 10:44 PM
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
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


Reply With Quote
  #5 (permalink)  
Old January 4th, 2008, 07:25 AM
Authorized User
 
Join Date: Dec 2007
Location: Liberec, , Czech Republic.
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
Reply With Quote
  #6 (permalink)  
Old January 10th, 2008, 01:55 AM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
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
Reply With Quote
  #7 (permalink)  
Old January 10th, 2008, 04:53 AM
Authorized User
 
Join Date: Dec 2007
Location: , , Vietnam.
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off




All times are GMT -4. The time now is 03:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.