Author |
Topic |
jhermiz
3564 Posts |
Posted - 2004-01-21 : 09:56:17
|
This fails on a null or no date<% Response.write(FormatDateTime(rs("DateSolved"), 2)) %>Can I check for the existance of this value like in vb?Jon |
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-01-21 : 10:01:14
|
i usually write my own VBScript formatting function to handle this. put them in a central library that you can INCLUDE in your scripts. something like:function FDT(Val) if isnull(val) then FDT = 'N/A' else FDT = formatDateTime(Val,2) end ifend function you get the idea ....- Jeff |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-21 : 10:20:12
|
Good morning Jeff,Thats prolly the question I have...I have noticed making a connection over and over is a pain...lets say my web host sits on a pcsay \\raptor with a folder "spi". Inside of here is my web content.Does this library need to exist in that path? What type of file is it? How would I call a function from this? Do I need to include it at the top of my asp pages. As well as keeping the connection information there...I'd like to be able to call functions like...EstablishConnection, which establishes a connection, and ReleaseConnection, which closes a connection.Any help is much appreciated. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-01-21 : 10:34:11
|
those are things you can store in a centralized "include" file that you will tell the server to dynamimcally merge that file with each ASP page. Each page just needs to have the "INCLUDE" line somewhere near the top. I still manually create each conneciton on each page, but the connection string is usually declared in an INCLUDEd file so you can maintain it in just in 1 place. I usually have a script for functions and things like that as well.Do a google for "ASP Server side includes". Here's a link I found that might be helpful:http://www.asp-help.com/getstarted/gs_includes.asp- Jeff |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-21 : 11:32:07
|
Hi Jeff...So is this right?Is this right for an SSI ??<%@ language=vbscript%><% Dim strConn = "Driver={SQL Server};" & _ "Server=HERCULES;" & _ "Database=myDB;" & _ "UID=myID;" & _ "PWD=myPass;"%><% function EstablishConnection() Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open strConn end function function ReleaseConnection() Conn.Close Set Conn=Nothing end function%> Remember I am very new...:-).Also if this is right where do I store it and how do I call it ?Thanks,Jon |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-21 : 12:30:56
|
This is not working...Here for example I have an html page inside\\myWebserver\www\spiThe html page has this content<html> <head> <title>Example of SSI</title> </head> <!--#include file="/spi/layout_top.html"--> <h1> Example of SSI </h1> The layout of this page is fully controlled by a common file. There are no BODY, COLOR or TABLE tags in this page. <!--#include file="/spi/layout_bottom.html"--> </html> I have layout_top.html that looks like this<body bgcolor="red"><table> <tr> <td valign="top"> side bar</td> <td valign="top"> And layout_bottom.html" with this:</td> </tr></table> But when I run this file by typing in:http://raptor/spi/t.htmlThe screen shows:Example of SSI The layout of this page is fully controlled by a common file. There are no BODY, COLOR or TABLE tags in this page. with no row or column or table and no RED!So apparently the SSI isnt working!Jon |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-01-21 : 13:43:10
|
you can't do this with HTML files, they must be ASP files. Settings for the web service tell the server which types of files can and cannot contain scripts and should be processed.- Jeff |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-21 : 14:34:04
|
quote: Originally posted by jsmith8858 you can't do this with HTML files, they must be ASP files. Settings for the web service tell the server which types of files can and cannot contain scripts and should be processed.- Jeff
Hmm...so all three pages MUST be asp files ?I dont get it...I just read an article which said it could be HTML files...maybe I misread? So all 3 files are .asp files correct? |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2004-01-21 : 14:41:54
|
The included files do not need to be ASP. The page that DOES the including needs to be .aspRename t.html to t.asp and try it again.Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-21 : 15:24:06
|
i get this:Active Server Pages error 'ASP 0130' Invalid File attribute /spi/t.asp, line 5 File attribute '/spi/layout_top.html' cannot start with forward slash or back slash. |
|
|
mohdowais
Sheikh of Yak Knowledge
1456 Posts |
Posted - 2004-01-22 : 04:52:21
|
Remove the "/spi/" bit. Simply:<!--#include file="layout_top.html"-->Wrapping your head around relative file paths takes a little getting used to, but you'll get to it eventually OS |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-22 : 08:27:12
|
would you look at that you're right.thank you guys.jon |
|
|
mkbosmans
Starting Member
15 Posts |
Posted - 2004-01-22 : 08:34:03
|
It's the file extension that matters. .shtml and .asp files get processed by the SSI-module. You can change the setup of IIS to include .html files in the list of extensions that get scanned foor SSI-commands. |
|
|
mkbosmans
Starting Member
15 Posts |
Posted - 2004-01-22 : 08:41:10
|
BTW, this is my custom routine for displaying a date.Function FormatGeneralDate(ByVal dtmInput, ByVal blnShort) FormatGeneralDate = "" If IsDate(dtmInput) Then dtmInput = CDate(dtmInput) If blnShort Then FormatGeneralDate = Day(dtmInput) & "-" & Month(dtmInput) & "-" & Year(dtmInput) If Not blnShort Then FormatGeneralDate = Right(Day(dtmInput)+100, 2) & "-" & Right(Month(dtmInput)+100, 2) & "-" & Year(dtmInput) End IfEnd Function Notes:- Its better to use IsDate then IsNull, so you also check for invalid date-strings.- I didn't use the build-in FormatDateTime function, because I wan't to make sure that the dates are displayed in the correct European date format (dd-mm-yyyy)- This function requires an extra boolean argument, to tell wether it should insert leading zero's to the day and month when < 10. |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-22 : 08:51:42
|
ok..im an idiot..im still having issues..I tried to create a file with this onlyConn.Open "Driver={SQL Server};" & _ "Server=HERCULES;" & _ "Database=myDB;" & _ "UID=myID;" & _ "PWD=myP;" As a file called "open_connection.html"Then I have an asp file that does this...snippet of code'---Dim the variablesDim ConnDim rs Set Conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") <!--#include file="open_connection.html"--> Set rs = Conn.Execute("SELECT * FROM Bugs ORDER BY DateRecorded") If(rs.eof) Then Response.write("No Records Found") End If %><tr><th width="112">Name</th> <th width="425">Description</th> <th width="143">Open Date</th> <th width="143">Closed Date</th> </tr><% do until rs.eof %> <tr> <td width="112"><center><% Response.write(rs("Name")) %></center></td> <td width="425"><center><% Response.write(rs("Description")) %></center></td> <td width="143"><center><% Response.write(FormatDateTime(rs("DateRecorded"), 2)) %></center></td> <td width="143"><center><% Response.write(FormatDateTime(rs("DateSolved"), 2)) %></center></td> </tr> <tr> <td colspan=5 width="690"><hr color="#333333" size="1"></td> </tr> <% rs.movenext loop rs.Close Set rs = nothing <!--#include file="close_connection.html"--> When I later go to this page it errors out :ADODB.Connection error '800a0e78' Operation is not allowed when the object is closed. /spi/bugs/results_page.asp, line 205 So apparently something is still wrong with this...What am I doing wrong still!!!!Also my last question on this SSI junk :-p..is can I define a bunch of functions in an SSI and then how would I call a specific function?Thanks,Jon |
|
|
jhermiz
3564 Posts |
Posted - 2004-01-22 : 13:18:33
|
Nevermind...I read this is a bad idea and the connection string should be somewhere else..sorry.Jon |
|
|
MichaelP
Jedi Yak
2489 Posts |
Posted - 2004-01-22 : 13:57:55
|
YesJust an FYI: open_connection.html neds to be an ASP page and you need <%%> around your connection stuff.Michael<Yoda>Use the Search page you must. Find the answer you will.</Yoda> |
|
|
|