We help IT Professionals succeed at work.






Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.

Hi all, I was just wondering if there was a way to restart a script if there was an error?

EG, I have an ASP script that runs every hour, however every now and then when backup is occuring it errors because it cannot write to the database that it is backing up.

Is there an If Error statement I can  use?
I want to craft a sql lookup utility on a classic asp website that has one required field and several optional fields.  How do i write a query that will look for the required field and then only the optional fields where a search filter has been supplied.  The required filter is LastName and the optional filters are FirstName, Gender, City, State, and Email.  Here is the query I have if only the LastName is provided:

    sql = "SELECT p.LastName, p.FirstName, ir.RaceID, ir.ChipTime, ir.ElpsdTime, ir.ChipStart FROM IndResults ir "
    sql = sql & "INNER JOIN Participant p ON ir.ParticipantID = p.ParticipantID WHERE p.LastName = '" & sLastName & "'"

Open in new window

Thank you very much!
I am trying to validate the presence and pattern of a field defined in an asp. net page.
The presence of the field works but when I enter the telephone number in the
field for pattern matching, it does not work. I get the error message.

Please advise,

<div visible="true" id="divTelephoneNumber" runat="server">
                  <div class="col-xs-12 col-md-8 col-sm-10 col-lg-6 nill">
					<asp:Label ID="lblTelephoneNumber" runat="server" AssociatedControlID="txtTelephoneNumber" Text="Telephone number *" CssClass="control-label" />
                      <br />
					<asp:TextBox ID="txtTelephoneNumber" runat="server" CssClass="form-control" MaxLength="20" aria-label="Telephone number" ></asp:TextBox>
					<span class="required"></span>
                    <asp:CustomValidator id="rfVTN" runat="server" ControlToValidate="txtTelephoneNumber"  ValidateEmptyText="true" ErrorMessage="Telephone Number is a required field. nnn-nnn-nnnn " ClientValidationFunction="ValidateTelephone"/> 

 <script type="text/javascript">
       function ValidateTelephone(sender, args) {
           var compare = RegExp("/^(\()?\d{3}(\))?(-|\s)?\d{3}(-|\s)\d{4}$/");
           args.IsValid = compare.test(args.Value);

Open in new window

I simply created a stored procedure that inserts data from an ASP page. I keep getting an error message "Failed to convert parameter value from a string to a boolean".
My Stored Procedure is
ALTER PROCEDURE [Merch].[MyStoredProcedure]
	@Suppint Varchar(50),
	@VendorCode Varchar(10),
	@classgroupAllocID Varchar(10),
	@Season Varchar(4),
	@quarter Varchar(50),
	@Month Varchar(50),
	@DateAllocated Date,
	@StyleCreated Varchar(5),
	@Category VARCHAR(50)
	INSERT INTO [Merch].[PurchasOrder] (Suppint,VendorCode,classgroupAllocID,Season,[quarter],CreateDate)
	VALUES (@Suppint,@VendorCode,@classgroupAllocID,@Season,@quarter,GETDATE());
	INSERT INTO [Merch].[purchasOrder2](POID,[Month],DateAllocated,StyleCreated,EDIT,Category,CreatDate) VALUES (@POID,@Month,@DateAllocated,@StyleCreated,@EDIT,@Category);

Open in new window

My vb code to take my web page objects into my sql server is the following.
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("MerchData").ConnectionString
        Dim con As New SqlConnection(strConnString)
        Dim cmd As New SqlCommand()
        cmd.CommandType = CommandType.StoredProcedure
        cmd.CommandText = "[Merch].[MyStoredProcedure]"
        cmd.Parameters.Add("@Suppint", SqlDbType.VarChar).Value = ddlSupplier.Text.Trim()
        cmd.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = tbsuppliercode.Text.Trim()

Open in new window

This code works great for adding up the # of sales by date, so we know how many sales per day.  I also want a separate query for money total for each day.  I've tried a bunch of different scenarios in SQL Studio, with no luck. Any advice would be appreciated!

Current Table:

PurchaseDate      TotalSales_Cnt1      TotalSales_Cnt2      TotalSales_Cnt3
2019-01-22               54                              8                               46
2019-01-23               50                              13                               37
2019-01-24               48                              10                               38
2019-01-25               51                              18                               33

New Table I'd like:
PurchaseDate      TotalSales_Cnt1      TotalSales_Cnt2      TotalSales_Cnt3
2019-01-22              $600                       $200                      $400

Column Names for money totals:
TotalSales_Cnt2 = Price
TotalSales_Cnt3 = TotalAmount

		Line1CTE AS
			(	Select	PurchaseDate	= cast(PurchaseDate as date)			
				,	TotalSales_Cnt1	= count(*)					
				from	(	select	PurchaseDate
						from	[DAL.ProductContext].[dbo].[SoldTABLE1Items]	
						union all						
						select	PurchaseDate
						from	[DAL.ProductContext].[dbo].[SoldTABLE2Items]	
					) a								
				By	cast(PurchaseDate as date)					
			Line2CTE AS									
			(	Select	PurchaseDate = cast(PurchaseDate as date)			
				,	TotalSales_Cnt2	= count(*)					

Open in new window

I've got a line chart working great, but want to added data from other recordsets, but I'm getting stuck.  I want to have 3 lines on my line chart basically.

I want this section: (1 line on the chart)
  ['<% response.write rs("PurchaseDate1") %>', <% response.write rs("TotalSales_Cnt1") %>],

To look like this: (3 lines on the chart)
  ['<% response.write rs("PurchaseDate1") %>', <% response.write rs("TotalSales_Cnt1") %>, <% response.write rs2("TotalSales_Cnt2") %>, <% response.write rs3("TotalSales_Cnt3") %>],

But don't know how to get there.  I can't figure out how to loop through all 3 to get the data in the AddRows section.


Any advice would be appreciated!!!


  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  <script type="text/javascript">
    google.charts.load('current', {packages: ['corechart']});

    function drawChart() {
      // Define the chart to be drawn.
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Date');
      data.addColumn('number', 'Total Sales');

<!-- MY CODE -->

Dim rs
Set rs = Server.CreateObject("ADODB.recordset")

Dim rs2
Set rs2 = Server.CreateObject("ADODB.recordset")

Dim rs3
Set rs3 = Server.CreateObject("ADODB.recordset")

SQL1 = "Select 

Open in new window

PDC is down but second DC is not opening. I tried to transfer the role by FSMO command line and successfully seize the role but the AD won't open.
Any help is helpful.
This code below looks up the number of sales per day, based on similar dates.  How can I add up the TotalSales_Cnt from TABLE1 and TABLE2?  I've tried INNER JOINS with no success.


Dim rs
Set rs = Server.CreateObject("ADODB.recordset")

SQL1 = "Select " & _ 
      "cast(PurchaseDate as date) PurchaseDate , count(*) TotalSales_Cnt " & _ 
      "from [DAL.ProductContext].[dbo].[SoldItemsTABLE1] " & _ 
      "Group By cast(PurchaseDate as date) " & _ 
      "order by 1 desc "

SQL2 = "Select " & _ 
      "cast(PurchaseDate as date) PurchaseDate , count(*) TotalSales_Cnt " & _ 
      "from [DAL.ProductContext].[dbo].[SoldItemsTABLE2] " & _ 
      "Group By cast(PurchaseDate as date) " & _ 
      "order by 1 desc "

rs.open SQL1, "DSN=dashboard"

response.write "<table border=1><tr><td><b>Sales Date</b></td><td><b>Total Sales TABLE1</b></td></tr>"
do while rs.eof = false
    response.Write("<tr><td>" & rs("PurchaseDate") & "</td><td>" & rs("TotalSales_Cnt") & "</td></tr" & vbcrlf)

response.write "</table>"


rs.open SQL2, "DSN=dashboard"

response.write "<table border=1><tr><td><b>Sales Date</b></td><td><b>Total Sales TABLE2</b></td></tr>"
do while rs.eof = false
    response.Write("<tr><td>" & rs("PurchaseDate") & "</td><td>" & rs("TotalSales_Cnt") & "</td></tr" & vbcrlf)

response.write "</table>"


Open in new window

I have some sales data, and each record has a purchase date.  I have multiple sales on each day, and want to count up how many sales per day based on the purchase date.  What's the best approach to be able to count them up, then print the results to the page?

Dim conn
Set conn = Server.CreateObject("ADODB.recordset")
conn.open "select * from [DAL.ProductContext].[dbo].[SoldItems] ORDER BY PurchaseDate DESC", "DSN=dashboard"

Open in new window

I am getting this error when running a simply query.

dates are saved in DB in this format yyyy-mm-dd. query string being sent to database is..

SELECT count(WoID) as Pending FROM WorkOrders WHERE ( (Status='Approved') OR (Status='Assigned') or (Status = 'Rejected') )

running this direct in SSMS works and return the correct result, there is no date involved in this query its just getting a record count.

Microsoft SQL Server Native Client 10.0 error '80040e07'

The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.

/cmms/common/db_obj.asp, line 94
I have an array of bib numbers (AsgndBibs) on our local machine and I want to find any of those that are not in the db on the server so I can insert them.  I have the insert down.  I just want to create an array of bibs that are not on the server (BibsToInsert).  The approach I am using requires opening a recordset for each bib in the array to see if it exists in the server.  There must be a better way.  I would appreciate any help I can get.  Thanks.  Below is how I am populating the BibsToInsert right now.

        j = 0
        ReDim BibsToInsert(0)
        For i = 0 To UBound(AsgndBibs) - 1
            Set rs = New ADODB.Recordset
            sql = "SELECT Bib FROM PartRace WHERE RaceID IN (" & sEventRaces & ") AND Bib = " & AsgndBibs(i)
            rs.Open sql, srvr_conn, 1, 2
            If Not rs.RecordCount > 0 Then
               BibsToInsert(j) = AsgndBibs(i)
               j = j + 1
               ReDim Preserve BibsToInsert(j)
            End If
            Set rs = Nothing
        Next i

Open in new window

I have a web application running in classic asp and I am currently using the crystal reports viewer to allow users to generate and download reports. My problem is I need to disable the IIS sessions and switch over to using cookies in order to handle a problem with query overlap on the web application. That is all working fine but the crystal reports viewer pages use sessions. Is there a way to run the crystal reports viewer without using sessions. Below is a sample of one of the crystal reports pages that  generate the reports.

<%@ Language=VBScript %>
Dim Report_Template
Dim basepath, baseVirtualPath, iLen
Dim Param1, Param2, ParamValue2, P2, P2R, ParamValueEndRange2
Dim curValue
Dim viewer
basePath = Request.ServerVariables("PATH_TRANSLATED")
While (Right(basePath, 1) <> "\" And Len(basePath) <> 0)
    iLen = Len(basePath) - 1
    basePath = Left(basePath, iLen)
Response.Write basePath
baseVirtualPath = Request.ServerVariables("PATH_INFO")
While (Right(baseVirtualPath, 1) <> "/" And Len(baseVirtualPath) <> 0)
    iLen = Len(baseVirtualPath) - 1
    baseVirtualPath = Left(baseVirtualPath, iLen)

If Not IsObject(session("oApp")) Then
    Set session("oApp") = Server.CreateObject("CrystalRuntime.Application.11")
    If Not IsObject(session("oApp")) Then
        response.write "Error:  Could not instantiate the Crystal Reports automation server.  Please check to see that Crystal Reports or ReCrystallize has been properly installed on the web server PC.  

Open in new window

Hello, All.

In my access database column, I have the following string of numbers and characters.

The column (CASTID) has the following

Open in new window

I have a code to use in ASP, but what I need now, is a query within access to get the number.

So, in this case, we are needing only 2011
And looking at the string, we have two 2011's
A single 2011
And at the end, 20119

We only want, returned what is searched for.
So in this case, the only record(s) we need returned is 2011.

Is I do a search with like
FROM Media
WHERE CastID Like "*2011*"

Open in new window

It returns all the numbers in the row but also finds records that do not have the number associated with it.

Looking to count the number of SQL records until a certain value in one of the table columns is reached. Using Asp /VBscript. Not sure how to formulate the query.

What I'd like is to organise the results by the column "points" in descending order, grouped by the "city_id". I then need the number of records counted until a specific "member_id" is matched. Some "points" values could also be the same, which can cause an incorrect count. Similar points values should be ignored.

the db table is named "rankings" and is structured like this:

id  |  member_id  |  city_id  |  points
1   |      1      |   12500   |    2
3   |      2      |   12500   |    5
4   |     34     |     800     |    1
5   |     14     |   12500   |    14
6   |      6      |     600     |    12
7   |     11     |   12500   |    11
8   |     12     |   12500   |    5

For example, if I want to find the ranking for member_id "2", who happens to belong to city_id "12500", the correct final returned value from should be 3. This is because member_id "2" has the third highest points value in city_id "12500", even after taking into account the tie in points with member_id "12".

This below is all I can think of as I'm not a pro by any means and I know it's missing a lot!

member_id = 2
city_id = 12500
SELECT Count() as city_ranking FROM (SELECT * from rankings WHERE city_id='"&city_id&"' AND member_id <> '"&member_id&"' ORDER BY points DESC)
Hello, All.

working on the last part of this project.
At least for the math anyway.

I have all my time in the database set as minutes.
90 = 1:30:00
So, what I need to do now, is convert the minutes into seconds.
90 = 5400

Everything I am finding is for the reverse.
Seconds into Minutes or hours.
Nothing for the opposite.

Any idea's on this one?
Hello, All.

I need to subtract time.
My output is the following format.

Time of Video = 01:30:00
Time played    = 00:07:17

I tried the accepted code from this post here. VBScript Time difference

I THINK I am using it correctly.
So, I tried the following.

theMTS = "00:07:17"
TTime = "01:30:00"


Open in new window

Output SHOULD be: 01:22:43

I get the following error.

Microsoft VBScript runtime error '800a000d'
Type mismatch: 'Cint'
/media/test2.asp, line 96

This is the line 96
BegTime = Cint(iStart)

Here is the code from the above-mentioned page.

Function SubtractTimes(iStart, iEnd)
' Given the following input values...
'    @TimBeg = 0815
'    @TimEnd = 1000
' the result should be 0145

Dim BegTime  ' Beginning time converted to an integer
Dim EndTime  ' Ending    time converted to an integer
Dim BH       ' Beginning hour converted to minutes since midnight
Dim BM       ' Beginning mins
Dim BT       ' Beginning time in minutes since midnight
Dim EH       ' Ending hour converted to minutes since midnight
Dim EM       ' Ending mins
Dim ET       ' Ending time in minutes since midnight
Dim TM       ' Total minutes in interval
Dim IH       ' Interval hours
Dim IM       ' Interval mins
Dim IT       ' 

Open in new window

Hello, All.
(For reference, I will be using ASP Classic in this project, however. That should not matter on how you submit the form to the data side.)

I am using HTML5 Video on my site.
I would like to capture the time the video stops at, and save it to my database.
(The database work I have completed)
What I need to know, is how to save the form, when the video is stopped?

here is a link to the video test page.

Here are the video and form code.
<video width="100%" height="100%" autobuffer controls id="myvideo" src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
<form name="displayurl" action="data/NewInsert.asp" method="post" onsubmit="xmlhttpPost('data/NewInsert.asp', 'displayurl', 'MotionDiv', '<img src=\'graph/pleasewait.gif\'>'); return false;">
        <input name="offseturl" type="text" readonly="" value="" size="50" onclick="document.displayurl.offseturl.focus();document.displayurl.offseturl.select();"/>
        <input type="hidden" name="Submit" value="Send Video Time" />
        <input type="hidden" name="UID" value="2" />
        <input type="hidden" name="MediaID" value="1" />
      <div id="MotionDiv"></div>

Open in new window

On this page, you can view the source.
I added a hidden button to get me a "Name" and "value" to call in the code for inserting the data into the database.

Any assistance on this would be great.
Hello, All.
(ASP Classic / Access Database)

OK, I am working on a project for our family home use.
In this project, I am using an Access Database.
(This makes it easier if I port it over to someone else's computer if they would like to use it.)

The column (CASTID) has the following

Open in new window

OK, let's say you only wanted to return the value for
How would you ask that in Access, that will work in ASP Classic?

I asked a similar question over here.
However, it is for SQL Server.

I tried the code from netminder, and I am uncertain about how to get it to work with my current project.

Hi there.

I have this table where I want to hide specific rows until a specific value is chosen from a Select-panel.
I can hide a textbox or other elements, but my code doesn't work for a table row. Any idea why?
Here's the Javascript:
<script type="text/javascript">
function Check() {
   if (document.getElementById('mm_comor_infectious_choice').value == "Yes") {
        document.getElementById('a1').style.display = 'block';
    else {
        document.getElementById('a1').style.display = 'none';



Open in new window

Here's the div-tags I "wrap" around the <tr></tr> in a table to hide it all until "Yes" is selected from the dropdown menu below:
<div id="a1" style="display:none" >

Open in new window

<select name="mm_comor_infectious_choice" id="mm_comor_infectious_choice" onchange="Check();">
        <option value="na" selected="selected"></option>
        <option value="Yes">Yes</option>
        <option value="No">No</option>

Open in new window

What's the trick to make it work? As mentioned: If I wrap a single element with the div-tags, then it works fine.

Best regards

We currently use ASPUpload and DropZonejs  to drag and drop files and then upload them to our server.

We are looking for a compatible script that will ZIP (compress) the files after the user drags and drops them in the "DropZone", and create one zip file which is the one that would be uploaded using ASPUpload.
Any recommendations on a script that would do this?

We need this for ASP Classic and also for NetCore.
Hi there.

Setup is classic asp and MS SQL Server...
When a new record is created, I use this code to create a unique ID for the record:

(CAST('" & xpatient_group & "' AS VARCHAR(1))+CAST('" & xinstitution & "' AS VARCHAR(2))+CAST(MAX(SUBSTRING(new_temp_patient_id, 4, 6))+1 AS VARCHAR(6))+CAST('" & xregimecode & "' AS VARCHAR(2)))

Open in new window

That works just fine for ages, but I WOULD like to catch that particular value created on the server and post back to the client, so it can be used in a query string and direct the user to that particular record.
Is that possible?

Best regards

javascript error
Not sure if I'm just being silly, but can't seem to get this script to work

function GetIP()
    var strIP
      strIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR");
    If strIP = "" Then strIP = Request.ServerVariables("REMOTE_ADDR");
    IP = strIP;
      document.form1.User_IP.value = IP;

My predecessor programmed our Intranet using ASP ages ago. There's code on a form submittal where it's using an Update statement to take away from the number showing in the database:

myConnString = Application("Flash_ConnectionString")	
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString
mySql="UPDATE OnHand SET ohnum = ohnum - 1 WHERE ohnum > 0"
myConnection.Execute mySQL
Set myConnection = Nothing

Open in new window

This works fine but we have since changed things to where the form allows the person to put any number for this item that we still need to subtract from the DB.

To make things easier, I call the value from the form and assign it to the variable s16: s16 = Request.Form("size16")

Then I try to get the Update statement to use my s16 var rather than the static number (mySql="UPDATE OnHand SET ohnum = ohnum - s16 WHERE ohnum > 0") and the web page returns this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/flash/Confirm.asp, line 233

Open in new window

Some things I do know:
1. Both ohnum and size16 are a Number data type in the Access DB
2. Via a Response.Write Command, I verified that the variable s16 does carry the correct information.

It's probably some kind of text/number mismatch but I cant seem to figure it out.

I have zero training with ASP so be gentle :)
Hello, All.

OK, what used to work, no longer work.
A multiple row insert, will now only, insert all into a single field.

environment: Windows 10 Pro / IIS
inserting into a Microsoft Office Access Database ACCDB
(This is a site for the intranet, and not for the internet. Which is the reason for using the access database)

Code, that used to work.

The form has all TEXTAREA's that are feeding into the insert form.

arrMN = Split(Request.Form("MediaName"), vbCrLf)  
arrMF = Split(Request.Form("MediaFile"), vbCrLf)  
arrMB = Split(Request.Form("MediaBand"), vbCrLf)  
for i=0 to uBound(arrMN)
  Set objDoubleInsert=CreateObject("ADODB.Command")  
  objDoubleInsert.CommandText = "INSERT INTO EVMediaServer (MediaName, MediaFile, MediaBand) VALUES (?,?,?)"  
  objDoubleInsert.Parameters.Append objDoubleInsert.CreateParameter("@MediaName", 200, 1, 255, arrMN(i)) 
  objDoubleInsert.Parameters.Append objDoubleInsert.CreateParameter("@MediaFile", 200, 1, 255, arrMF(i))  
  objDoubleInsert.Parameters.Append objDoubleInsert.CreateParameter("@MediaBand", 200, 1, 255, arrMB(i))  

Open in new window

before, this code used to create as many rows as I had in the fields.
But now, all of it is inserted into ONE ROW, and all the lines are in one column.

What is going on?
Thanks for any and all assistance on this one.

Hi there.

I have a web database with classic asp, VB and javascript in the front end. I want to rebuild the entire web interface in aspx (VB edition).
I know classic asp pretty well. It's simple in the file structure. I tried starting up an aspx-project, and software like Visual Studio creates a bunch of files that is hard to overview and mess up the global web-files.
1) Is there any possible way to make a "simple" aspx-site where you control the whole thing and Visual Studio doesn't create a lot of files that are hard to overview?
2) Would it be possible to create an aspx-site on the same server as the classic asp?
3) Any free software that keeps aspx more simple than Visual Studio?

Best regards







Active Server Pages (ASP) is Microsoft’s first server-side engine for dynamic web pages. ASP’s support of the Component Object Model (COM) enables it to access and use compiled libraries such as DLLs. It has been superseded by ASP.NET, but will be supported by Internet Information Services (IIS) through at least 2022.