Click to See Complete Forum and Search --> : quick bit of help with some code
airwolfdirectuk
04-21-2006, 05:10 AM
Amending a script written for my work, orginal picked up a customers weburl and forwarded you to it.
Trying to amend for a supplier, basic problem is the script has to reference to something. see below:
rs.Source="select isnull(weburl,'') as WebUrl from suppliers where [code]=(select PostingAccount from suppliers where [Code]='" & sCode & "')"
what i need to know is i need is to know how to change "where [Code]='" & sCode & "')" " so that is basically says that these two values are the same.
Thanks
Rob
Terrorke
04-21-2006, 06:06 AM
I'm not sure what you want to do??
You are trying to compare two columns in the same table??
Try this than :
select isnull(weburl) from suppliers where [code]=postingAccount
airwolfdirectuk
04-21-2006, 06:22 AM
yes, trying to compare to values in the same table, if these match then display the weburl of that customer. Tried the suggestion, did not work
Rob
Terrorke
04-21-2006, 07:17 AM
Can you please give us the code your are trying?
Its easier to look for mistakes
airwolfdirectuk
04-21-2006, 07:20 AM
so far i'm on this code:
<%@ Language=VBScript %>
<%Option Explicit%>
<!--#Include file="includes/adovbs.inc"-->
<!--#Include file="includes/tharsternconstants.inc"-->
<!--#Include file="includes/tharsternconnect.asp"-->
<%
Dim sCode
Dim sSQL
Dim rs
Dim sWebUrl
sCode=Request("Code")
set rs=Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection=cnnTharstern
rs.CursorLocation=adUseClient
rs.Source="select isnull(weburl,'') as WebUrl from suppliers where Code =(PostingAccount)"
rs.Open ,,adOpenForwardOnly,adLockReadOnly,adCmdText
if rs.State<>adStateClosed then
if not rs.EOF then
sWebUrl=rs(0)
end if
end if
set rs=nothing
if sWebUrl<>"" then
Response.Redirect sWebUrl
else
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
No Web URL for this supplier
</BODY>
</HTML>
<%
end if
%>
<!--#Include file="includes/tharsterndisconnect.asp"-->
Terrorke
04-21-2006, 09:19 AM
Try using :
rs.Source="select isnull(weburl,'') as WebUrl from suppliers where Code =PostingAccount"
Why are u using isnull(weburl,'')??
russell
04-21-2006, 07:20 PM
Your query
rs.source = "" &_
"select isnull(weburl,'') as WebUrl " &_
"from suppliers " &_
"where [code] = PostingAccount " &_
"and [Code]='" & sCode & "'"