ASP not showing any data after repair

A

Amateur

Dear Sirs
Some days ago I received an error message for my Globalsub.asp .
With you Forums help I repaired it (a part of the code is below)
Since it is repaired my ASP pages are not showing any data anymore. Here is
the code . Can someone tell me what I have done wrong?

<%@Language="VBScript"%>
<% OPTION EXPLICIT %>
<%
Response.Buffer = True
Response.expiresAbsolute=Now()-10
Response.expires=0
Response.addHeader "pragma","no-cache"
Response.addHeader "cache-control","private"


Dim CR
Dim LF
Dim CrLf
Dim QU
Dim Qs
CR=Chr(13)
LF=Chr(10)
CrLf=Chr(13)+Chr(10)
QU = Chr(34)
Qs = Chr(39)

Function FillFromDb(Tablename, Fieldname)
Set connFillFromDb = server.CreateObject("adodb.Connection")
connFillFromDb.Open
"dsn=access;database=f:\www.xxxxxxxxxxxxxxxxxxxxx.com\data\transferdb.mdb"
Sqlstr = "SELECT " + Fieldname + " FROM "+ Tablename
Set rsFillFromDb = connFillFromDb.Execute(Sqlstr)
TmpStr = ""
While rsFillFromDb.EOF <> True
If isnull(rsFillFromDb(Fieldname)) <> true then
TmpStr = TmpStr + CStr(Trim(rsFillFromDb(Fieldname))) + ";"
End if
rsFillFromDb.MoveNext
Wend
FillFromDb = Mid(TmpStr, 1, Len(TmpStr)+1)
rsFillFromDb.Close
connFillFromDb.Close
End Function

Function CreateSelectWithKey(Tablename, Fieldname, Keyname, ataffieldname,
curvalue, defaultvalue, sizeofbox, style)
Set connFillFromDb = server.CreateObject("adodb.Connection")
connFillFromDb.Open
"dsn=access;database=f:\www.xxxxxxxxxx.com\data\transferdb.mdb"
Sqlstr = "SELECT " + Fieldname +"," +Keyname+" From " + Tablename
Set rsFillFromDb = connFillFromDb.Execute(Sqlstr)
TmpStr = ""
TmpStr = "<select "+style+" size="+qu+ sizeofbox +qu+" name="
+qu+ataffieldname+qu+ ">"+ Crlf
If curvalue="" Then curvalue=defaultvalue
While rsFillFromDb.EOF <> True
If isnull(rsFillFromDb(Keyname)) <> true then
If CStr(Trim(rsFillFromDb(Keyname)))=curvalue Then
TmpStr = TmpStr +"<option selected
value="+qu+Trim(CStr(rsFillFromDb(Keyname)))+qu+">"+Trim(CStr(rsFillFromDb(Fieldname)))+"</option>"+Crlf
Else
TmpStr = TmpStr +"<option
value="+qu+Trim(CStr(rsFillFromDb(Keyname)))+qu+">"+Trim(CStr(rsFillFromDb(Fieldname)))+"</option>"+Crlf
End if
 
S

Stefan B Rusynko

Start here http://www.w3schools.com/asp/default.asp
- see Procedures for info on Functions

Neither of those 2 Functions will do anything in a page by themselves
- unless they are called by script passing valid parameters to them

Suggest you go to where you copied the scripts from and reread the usage instructions



PS
The + is not the recommended string concatenator in VBscript
(it is used for addition of parameters and you should be using the & to avoid ambiguity in your scripts)
- so all your strings using + may not concatenate correctly
Reset them all to below:
Sqlstr = "SELECT " & Fieldname & " FROM " & Tablename

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| Dear Sirs
| Some days ago I received an error message for my Globalsub.asp .
| With you Forums help I repaired it (a part of the code is below)
| Since it is repaired my ASP pages are not showing any data anymore. Here is
| the code . Can someone tell me what I have done wrong?
|
| <%@Language="VBScript"%>
| <% OPTION EXPLICIT %>
| <%
| Response.Buffer = True
| Response.expiresAbsolute=Now()-10
| Response.expires=0
| Response.addHeader "pragma","no-cache"
| Response.addHeader "cache-control","private"
|
|
| Dim CR
| Dim LF
| Dim CrLf
| Dim QU
| Dim Qs
| CR=Chr(13)
| LF=Chr(10)
| CrLf=Chr(13)+Chr(10)
| QU = Chr(34)
| Qs = Chr(39)
|
| Function FillFromDb(Tablename, Fieldname)
| Set connFillFromDb = server.CreateObject("adodb.Connection")
| connFillFromDb.Open
| "dsn=access;database=f:\www.xxxxxxxxxxxxxxxxxxxxx.com\data\transferdb.mdb"
| Sqlstr = "SELECT " + Fieldname + " FROM "+ Tablename
| Set rsFillFromDb = connFillFromDb.Execute(Sqlstr)
| TmpStr = ""
| While rsFillFromDb.EOF <> True
| If isnull(rsFillFromDb(Fieldname)) <> true then
| TmpStr = TmpStr + CStr(Trim(rsFillFromDb(Fieldname))) + ";"
| End if
| rsFillFromDb.MoveNext
| Wend
| FillFromDb = Mid(TmpStr, 1, Len(TmpStr)+1)
| rsFillFromDb.Close
| connFillFromDb.Close
| End Function
|
| Function CreateSelectWithKey(Tablename, Fieldname, Keyname, ataffieldname,
| curvalue, defaultvalue, sizeofbox, style)
| Set connFillFromDb = server.CreateObject("adodb.Connection")
| connFillFromDb.Open
| "dsn=access;database=f:\www.xxxxxxxxxx.com\data\transferdb.mdb"
| Sqlstr = "SELECT " + Fieldname +"," +Keyname+" From " + Tablename
| Set rsFillFromDb = connFillFromDb.Execute(Sqlstr)
| TmpStr = ""
| TmpStr = "<select "+style+" size="+qu+ sizeofbox +qu+" name="
| +qu+ataffieldname+qu+ ">"+ Crlf
| If curvalue="" Then curvalue=defaultvalue
| While rsFillFromDb.EOF <> True
| If isnull(rsFillFromDb(Keyname)) <> true then
| If CStr(Trim(rsFillFromDb(Keyname)))=curvalue Then
| TmpStr = TmpStr +"<option selected
| value="+qu+Trim(CStr(rsFillFromDb(Keyname)))+qu+">"+Trim(CStr(rsFillFromDb(Fieldname)))+"</option>"+Crlf
| Else
| TmpStr = TmpStr +"<option
| value="+qu+Trim(CStr(rsFillFromDb(Keyname)))+qu+">"+Trim(CStr(rsFillFromDb(Fieldname)))+"</option>"+Crlf
| End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top