Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic 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 April 14th, 2005, 02:43 PM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening an SQL table in a function


How do I open a table in a procedure?
I creating a connection to my sql server on the header of the ASP code with the following string and I have no problem with this.

However, when I want to open a AGENT table in a function, I am getting an error.

Here is my code.

ASP PAGE:

<%
'**to set field value
sqlvarMarket= "SELECT TOP 100 PERCENT MarketStaffID,MarketAreaCode, MarketDescription FROM dbo.MarketAreaTable ORDER BY MarketDescription"
Set revarMarket = conn.Execute(sqlvarMarket) %>

HERE IS PART OF THE BODY:
<select name="selectMarket" size="1" style="width:150;COLOR:#669966;">
<option value=0 selected>Market....</option>
<% do until reMarket.EOF
response.write "<option value= " & reMarket("MarketAreaCode") & "> " & reMarket("MarketDescription") & "</option>"
reMarket.MoveNext
loop
reMarket.close
Set reMarket = Nothing
%>

this is where I get the error
HERE IS THE FUNCTION CALLED WHEN THE selectMarket FIELD IS CHANGED:
Function selectMarket_OnChange
y=Document.form1.selectMarket.value
sqlAgent="SELECT TOP 100 PERCENT EnteredBy, id AS AgentID, Company FROM dbo.AgentInformation WHERE MarketID=" & y
sqlAgent=sqlAgent & " ORDER BY EnteredBy, Company"
set reAgent=conn.execute(sqlAgent)
End Function


HERE IS THE CONTENT OF THE CONNECTDB.TXT
Set conn = Server.CreateObject(ADODB.Connection)
conn.ConnectionTimeout = 30
conn.CommandTimeout = 30

conn.Open (my connection string)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening SQL 2000 Jobs in SQL 2005 carumuga SQL Server 2005 0 June 16th, 2008 05:00 AM
Pivot Table Fields Function gastoncs Excel VBA 3 January 16th, 2006 07:04 AM
opening an Access table from VB6 dartcoach Access 32 December 24th, 2005 03:01 AM
could i join function(return table) with a table alyeng2000 SQL Server 2000 6 September 30th, 2004 07:23 AM
Opening unknown table names NiMot VB Databases Basics 2 July 17th, 2003 02:37 PM





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