Showing posts with label menus. Show all posts
Showing posts with label menus. Show all posts

Thursday, March 22, 2012

ASP data access difficulties

I'm using ASP pages to access a Microsoft SQL 2005 SP1 database server for information that populates dropdown menus. I ran into an interesting problem. We can query all existing data without a problem (all expected rows return and correctly populate the dropdowns).

I manually add a new row to the database table for a dropdown. I can manually query the database from the SQL2005 management tool, and the new records are included in the results.

I load the ASP page, and the newly added records never appear in the dropdown... only the old, existing data.

What could cause this? The queries from ASP are the same as the queries I make directly from the SQL server.

Could you please post the part of your code that is filling the dropdown boxes ?

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

-relevant snip-

<% SQL = "sp_GetVMFarmList"
set rs = conn.execute(SQL) %>
<select name="VMFarm" class="InputBox">
<option></option>
<% while not rs.eof
strSelected = ""
if intFarmID <> "" then
if cint(intFarmID) = cint(rs("FarmID")) then
strSelected = "Selected"
end if
end if %>
<option <%=strSelected %> value="<%=rs("FarmID")%>"><%=rs("FarmName")%></option>

<% rs.movenext
wend %>
</select>

|||

Any page directives or server settings to cache the pages ? BTW you should not use sp_ prefixes as SQL will *always* do a recompilation to the procedures as the prefix is reserved for system procedures. Better use usp_Something or spSomething.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||No caching, nothing on the web server (IIS 6) has changed. I restarted the IIS service several times to make sure it wasn't trying to hold onto any data|||

Probably a silly question, but have you checked from another computer to make sure your computer isn't caching the data?

|||

Oh yes... in fact it was several other users reporting that they couldn't see the new data I added to the tables. they all use different PCs.

|||

I assume you've made a backup of your data Smile If not, that would be my first step right now. Now I'm going to go into what I call "guess mode because I don't really know what's going on"....

Then I would start playing with it, see if the website even recognizes any sort of change, such as removing some rows. If nothing is responding I would drop the table and reload it and see if that helps. However, like I said, you definitely need to have a backup of your data because you never know how the reloading stage might go.

|||When you say "I can manually query the database from SQL2005 management tool", you mean you run sp_GetVMFarmList, or you are doing the query that is defined in the stored procedure?|||

Both

|||

try Response.Expires = 0 at the top of the ASP page, to make sure you don't have some additional caching. But probably you should now examine your update code, instead of the dropdown code.

ASP data access difficulties

I'm using ASP pages to access a Microsoft SQL 2005 SP1 database server for information that populates dropdown menus. I ran into an interesting problem. We can query all existing data without a problem (all expected rows return and correctly populate the dropdowns).

I manually add a new row to the database table for a dropdown. I can manually query the database from the SQL2005 management tool, and the new records are included in the results.

I load the ASP page, and the newly added records never appear in the dropdown... only the old, existing data.

What could cause this? The queries from ASP are the same as the queries I make directly from the SQL server.

Could you please post the part of your code that is filling the dropdown boxes ?

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

-relevant snip-

<% SQL = "sp_GetVMFarmList"
set rs = conn.execute(SQL) %>
<select name="VMFarm" class="InputBox">
<option></option>
<% while not rs.eof
strSelected = ""
if intFarmID <> "" then
if cint(intFarmID) = cint(rs("FarmID")) then
strSelected = "Selected"
end if
end if %>
<option <%=strSelected %> value="<%=rs("FarmID")%>"><%=rs("FarmName")%></option>

<% rs.movenext
wend %>
</select>

|||

Any page directives or server settings to cache the pages ? BTW you should not use sp_ prefixes as SQL will *always* do a recompilation to the procedures as the prefix is reserved for system procedures. Better use usp_Something or spSomething.

Jens K. Suessmeyer

http://www.sqlserver2005.de

|||

No caching, nothing on the web server (IIS 6) has changed. I restarted the IIS service several times to make sure it wasn't trying to hold onto any data|||

Probably a silly question, but have you checked from another computer to make sure your computer isn't caching the data?

|||

Oh yes... in fact it was several other users reporting that they couldn't see the new data I added to the tables. they all use different PCs.

|||

I assume you've made a backup of your data Smile If not, that would be my first step right now. Now I'm going to go into what I call "guess mode because I don't really know what's going on"....

Then I would start playing with it, see if the website even recognizes any sort of change, such as removing some rows. If nothing is responding I would drop the table and reload it and see if that helps. However, like I said, you definitely need to have a backup of your data because you never know how the reloading stage might go.

|||When you say "I can manually query the database from SQL2005 management tool", you mean you run sp_GetVMFarmList, or you are doing the query that is defined in the stored procedure?

|||

Both

|||

try Response.Expires = 0 at the top of the ASP page, to make sure you don't have some additional caching. But probably you should now examine your update code, instead of the dropdown code.

ASP and SQL2000 drop-down menu

Okay, I am new to this so be gental.
I have a form with 2 drop down menus and a text field that I am concerned
with. Size, Packaging, and Cost. Size and Packaging pull their info from a
Size and a Packaging table respectively. I need the third field, Cost, to
take the values selected by the user in the Size and Packaging fields, and
use those values to query a third table "Cost." The Cost Table has three
fields: Size, Packaging, and Cost (The cost field is always different
depending on the Size and Packaging chosen).
I have created a server side procedure:
Create Procedure getmycost
@.size int,
@.packaging varchar(50),
@.cost money OUT
AS
Select @.cost=Cost
From Cost
Where
Size = @.size AND
Packaging = @.packaging
I have placed the this code on the client side within Cost the field:
declare @.size int, @.packaging varchar(50), @.cost money
set @.size=Size
set @.packaging=Packaging
Execute getmynumber @.size,@.packaging,@.cost OUT
select @.cost
I am sure I am doing this all wrong;
I am geting an error:
Invalid column name 'Size'
Is this not the way to reference a field on the web form (Size)?
And will this even work?Hi
Did you check out the links in your previous post?
John
"HollyylloH" wrote:

> Okay, I am new to this so be gental.
> I have a form with 2 drop down menus and a text field that I am concerned
> with. Size, Packaging, and Cost. Size and Packaging pull their info from a
> Size and a Packaging table respectively. I need the third field, Cost, to
> take the values selected by the user in the Size and Packaging fields, and
> use those values to query a third table "Cost." The Cost Table has three
> fields: Size, Packaging, and Cost (The cost field is always different
> depending on the Size and Packaging chosen).
> I have created a server side procedure:
> Create Procedure getmycost
> @.size int,
> @.packaging varchar(50),
> @.cost money OUT
> AS
> Select @.cost=Cost
> From Cost
> Where
> Size = @.size AND
> Packaging = @.packaging
> I have placed the this code on the client side within Cost the field:
> declare @.size int, @.packaging varchar(50), @.cost money
> set @.size=Size
> set @.packaging=Packaging
> Execute getmynumber @.size,@.packaging,@.cost OUT
> select @.cost
> I am sure I am doing this all wrong;
> I am geting an error:
> Invalid column name 'Size'
> Is this not the way to reference a field on the web form (Size)?
> And will this even work?
>|||Yes I did check them out. No I can't answer my question from them.
"John Bell" wrote:
> Hi
> Did you check out the links in your previous post?
> John
> "HollyylloH" wrote:
>