Welcome, Guest ( Customer Panel | Login )




 All Forums
 VPCart Forum
 Problems and bugs
 reference database field from asp
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

faolie
VP-CART New User

98 Posts

Posted - October 02 2007 :  04:30:33  Show Profile  Visit faolie's Homepage  Reply with Quote
Is it possible to access a pother field directly from asp? Current code (which works fine) accesses a file directly and looks like this:

tfm_downloadStream.LoadFromFile Server.Mappath("filepath")

What I want is to use a pother field to hold the filepath so that the code looks sort of like this:

tfm_downloadStream.LoadFromFile Server.Mappath("pother2").

I realise that that's somewhat simplified, but can anyone help here?

thanks

David Heriot

devshb
Senior Member

United Kingdom
1904 Posts

Posted - October 02 2007 :  05:08:35  Show Profile  Visit devshb's Homepage  Reply with Quote
you'd need to create a function for it, paste that function inside shop$db.asp so that any asp can use it, and then call the function with the pother argument from your asp.

so you'd paste something like this inside shop$db.asp:

Function BYZ_CUS_GET_PRODUCT_VALUE(arg_in_catalogid,arg_in_columnname)
Dim tconn
Dim tsql
Dim trs
Dim tval
tval=""
ShopOpenDatabaseP tconn
tsql="select * from products"
tsql=tsql&" where catalogid="&arg_in_catalogid
Set trs=tconn.Execute(tsql)
if (trs.Eof) then
else
While(NOT trs.EOF)
tval=trs(arg_in_columnname)
trs.movenext
Wend
end if
trs.Close
Set trs=Nothing
ShopCloseDatabase tconn
BYZ_CUS_GET_PRODUCT_VALUE=tval
End Function


and then inside your asp you'd get a product value like this:


Response.Write BYZ_CUS_GET_PRODUCT_VALUE(100,"pother2")

where 100 is your catalogid of the product

but if you want to reference a product column from a normal product page then it's much simpler; you'd just put the column name in square brackets in your product template (tmp_product.htm for product-detail and tmp_productformat.htm for product-summary)

Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons

Edited by - devshb on October 02 2007 05:10:45
Go to Top of Page

faolie
VP-CART New User

98 Posts

Posted - October 16 2007 :  03:36:09  Show Profile  Visit faolie's Homepage  Reply with Quote
Simon

thanks for taking the trouble to answer. Can you advise one more thing: if I didn't want to write but simply refer to the file name in pother2 as in the example (it's the location of an mp3 file to download), can I still just follow your code to achieve this? Or I am not following the logic properly?

regards

David Heriot
Go to Top of Page

devshb
Senior Member

United Kingdom
1904 Posts

Posted - October 16 2007 :  04:16:47  Show Profile  Visit devshb's Homepage  Reply with Quote
yes, the function returns the value, so you can set a variable to its contents and then play with the variable, or add an if statement to only show things if it's not null etc

eg

Dim mymp3file
mymp3file=BYZ_CUS_GET_PRODUCT_VALUE(100,"pother2")

if (mymp3file<>"" and IsNull(mymp3file)=false) then
Response.Write "< all your mp3 play tags start>"
Response.Write mymp3file
Response.Write "</ all your mp3 play tags end>"
end if




Simon Barnaby
Developer
[email protected]
www.BigYellowZone.com
Web Design, Online Marketing and VPASP addons
Go to Top of Page

Trial_and_Error
Starting Member

36 Posts

Posted - March 19 2009 :  20:27:14  Show Profile  Reply with Quote
Hello,

I'm trying to adapt the setcontinueurl routine in the shopaddtocart. The purpose is to "remember" the categoryid and the catdescription from the product added to cart after clicking the order button in shopexd.asp.

So, similar to the code posted before in this topic, I created 2 functions "Bepaalkategorie" and "Bepaalkategorienaam" in shop$db (see below):

Function Bepaalkategorie(arg_in_catalogid,arg_in_columnname)
Dim tconn
Dim tsql
Dim trs
Dim tval
tval=""
ShopOpenDatabaseP tconn
tsql="select * from products"
tsql=tsql&" where catalogid="&arg_in_catalogid
Set trs=tconn.Execute(tsql)
if (trs.Eof) then
exit function
else
While(NOT trs.EOF)
tval=trs(arg_in_columnname)
trs.movenext
Wend
end if
trs.Close
Set trs=Nothing
ShopCloseDatabase tconn
Bepaalkategorie=tval
End Function

Function Bepaalkategorienaam(arg_in_categoryid,arg_in_columnname)
Dim tconn
Dim tsql
Dim trs
Dim tval
tval=""
ShopOpenDatabaseP tconn
tsql="select * from categories"
tsql=tsql&" where categoryid="&arg_in_categoryid
Set trs=tconn.Execute(tsql)
if (trs.Eof) then
exit function
else
While(NOT trs.EOF)
tval=trs(arg_in_columnname)
trs.movenext
Wend
end if
trs.Close
Set trs=Nothing
ShopCloseDatabase tconn
Bepaalkategorienaam=tval
End Function


Secondly, I added the following to the sub "displayform" in shopaddtocart :

produktkategorie=Bepaalkategorie(prodid,"ccategory")
response.write produktkategorie
produktkategorienaam=Bepaalkategorienaam(produktkategorie,"catdescription")
response.write produktkategorienaam
nieuwelink="shopdisplayproducts.asp?id=" & produktkategorie & "&cat=" & produktkategorienaam
response.write nieuwelink

Thirdly, I changed sub setcontinueurl in shopaddtocart like below :

Sub SetContinueurl (continueurl)
dim pagefrom, words(20),wordcount,id
'dim prodid
'dim produktkategorie, produktkategorienaam, nieuwelink
pagefrom= request.servervariables("http_referer")
parserecord pagefrom, words, wordcount,"/"
'VP-ASP 6.09 - changed below to be more flexible
'if lcase(words(wordcount-1))<>"shopaddtocart.asp" then
if (instr(lcase(words(wordcount-1)),"shopaddtocart.asp") = 0) AND (instr(lcase(words(wordcount-1)),"shopdeliveryedit.asp") = 0) then
setsess "pagefrom",pagefrom
else
pagefrom=getsess("pagefrom")
if pagefrom="" then
pagefrom=getconfig("xcontinueurl")
end if
end if

continueurl="shopdisplayproducts.asp?id=" & produktkategorie & "&cat=" & produktkategorienaam
'continueurl=nieuwelink
'continueurl=pagefrom
If getconfig("xdebug")="Yes" then
debugwrite "will return to " & continueurl
end if
end Sub

The problem is that the link is not correctly working when I push the continue shopping button. I mostly get 2 errors depending on how I adapt the code.

Sometimes the error is that 'catalogid' is missing in my shop$db, sometimes the link is referring to

http://localhost/site/shopdisplayproducts.asp?id=&cat=

so the catnr and catname is not displayed and left blank. This is strange, because

response.write produktkategorie and response.write produktkategorienaam does display the correct categorieid and name on my page. So I assume that my code is working correctly, but the link is not.

Can somebody explain this to me or help me out?

Thanks,
Trial_and_error
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000
0 Item(s)
$0.00