newmediaguy
Programmer
Hi Guys
I have a Function in an include file that searches across multiple tables to find product in formation. What i would like to do is to show a results total on the screen when a sub parameter has been chosen.
What currently is returned is the total for the initial search, when a sub select is specified this total doesnt update........
Here is the code
Any help or advice would be very much appreciated.
Many thanks
Glen
I have a Function in an include file that searches across multiple tables to find product in formation. What i would like to do is to show a results total on the screen when a sub parameter has been chosen.
What currently is returned is the total for the initial search, when a sub select is specified this total doesnt update........
Here is the code
Code:
FUNCTION ResultValue(TPID, Requested_Field)
'no cnet content found.
'Response.Write("TPID: "&TPID&"<br>")
'look for this product id in the main product table.
set ProductTable = server.CreateObject("ADODB.Recordset")
ProductTable.ActiveConnection = MM_tpsqltest_STRING
ProductTable.Source = "SELECT * FROM ProductTable WHERE TPID = '"&TPID&"'"
ProductTable.Open()
ProductTable_Counter = 0
While (NOT ProductTable.EOF)
'set the supplier id varialbe
SupplierID = ProductTable("SupplierID")
ProductTable_Counter = ProductTable_Counter + 1
ProductTable.MoveNext
Wend
ProductTable.Close()
'Response.Write("SupplierID: "&SupplierID&"<br>")
'we have the supplier ID....
'so we now need to look in the product supplierdatacolumns to get the table name.
set the_table = server.CreateObject("ADODB.Recordset")
the_table.ActiveConnection = MM_tpsqltest_STRING
the_table.Source = "SELECT DISTINCT ProductTable FROM SupplierDataColumns WHERE SupplierID = '"&SupplierID&"'"
the_table.Open()
the_table_counter = 0
While (NOT the_table.EOF)
'we have found the table name
DataTable = the_table("ProductTable")
the_table_counter = the_table_counter + 1
the_table.MoveNext
Wend
the_table.Close()
'we need to get the related column name from the column name requested.
set related_data = server.CreateObject("ADODB.Recordset")
related_data.ActiveConnection = MM_tpsqltest_STRING
related_data.Source = "SELECT * FROM SupplierDataColumns WHERE HigherName = '"&Requested_Field&"' AND SupplierID = '"&SupplierID&"'"
related_data.Open()
related_data_counter = 0
While (NOT related_data.EOF)
Output_Field = related_data("FieldName")
related_data_counter = related_data_counter + 1
related_data.MoveNext
Wend
related_data.Close()
'get the prodid from the table.
set getid = server.CreateObject("ADODB.Recordset")
getid.ActiveConnection = MM_tpsqltest_STRING
getid.Source = "SELECT * FROM SupplierDataColumns WHERE HigherName = 'TPID' AND SupplierID = '"&SupplierID&"'"
getid.Open()
While (NOT getid.EOF)
IDColumn = getid("FieldName")
getid.MoveNext
Wend
getid.Close()
If ProductTable_Counter = 0 then
Final_Output_Value = "Sorry"
Else
'we have found the column that we need to look up in the certain table to get the results required.
set myOutput = server.CreateObject("ADODB.Recordset")
myOutput.ActiveConnection = MM_tpsqltest_STRING
myOutput.Source = "SELECT * FROM "&DataTable&" WHERE "&IDColumn&" = '"&TPID&"'"
'Response.Write("SELECT * FROM "&DataTable&" WHERE "&IDColumn&" = '"&TPID&"'")
myOutput.Open()
While (NOT myOutput.EOF)
Final_Output_Value = myOutput(""&Output_Field&"")
myOutput.MoveNext
Wend
myOutput.Close()
End if
'output
ResultValue = Final_Output_Value
END FUNCTION
Any help or advice would be very much appreciated.
Many thanks
Glen