ASP

81K

Solutions

31K

Contributors

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.

Share tech news, updates, or what's on your mind.

Sign up to Post

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)
    rs.movenext
loop

response.write "</table>"

rs.Close 

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)
    rs.movenext
loop

response.write "</table>"

%>

Open in new window

0
Exploring ASP.NET Core: Fundamentals
LVL 13
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

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

0
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
0
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)
Wend
Response.Write basePath
baseVirtualPath = Request.ServerVariables("PATH_INFO")
While (Right(baseVirtualPath, 1) <> "/" And Len(baseVirtualPath) <> 0)
    iLen = Len(baseVirtualPath) - 1
    baseVirtualPath = Left(baseVirtualPath, iLen)
Wend

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

0
Hello, All.

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

The column (CASTID) has the following
4807/11056/11055/11054/11053/2011/11052/11051/11050/10897/11049/20119/

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
SELECT CastID
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.

Thanks.
Wayne
0
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?
0
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"

SubtractTimes(theMTS,TTime)

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

0
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.)

OK.
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.
https://www.cffcs.com/stuff/VideoTest.asp

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">
</video>
<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" />
      </form>
      <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.
Thanks.
Wayne
0
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
4807/11056/11055/11054/11053/2011/11052/11051/11050/10897/11049/

Open in new window


OK, let's say you only wanted to return the value for
2011
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.

Wayne
0
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';

   }
}

</script>

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" >
</div>

Open in new window


Select-panel:
<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>
      </select>

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

Ulrich
0
Become a Certified Penetration Testing Engineer
LVL 13
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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.
0
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;

}
0
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
myConnection.Close
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 :)
0
Experts - Can someone give me code samples for Classic asp with EWS connection please?

Classic asp and not .Net
0
I use the following asp net email validator and it works fine until today I get an email (jsmiths@ca--homes.com).
And I want to ensure to accept this string '--'.

how can I do that with my current email validator?


<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
            ControlToValidate="NewEmailAddressTextBox" CssClass="red bold"
            Display="Dynamic" ErrorMessage="*"
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
            ValidationGroup="AddNewEmail"></asp:RegularExpressionValidator>
0
I am trying to create 2 web pages using Classic ASP. I know it's outdated now, but I used to write in it many years ago, and have mostly forgotten it all. It's just for a way of displaying all of the video files I have for each tape. So one tape (tbl_tape) will have many video file (tbl_video_file), linked by tape_id - fk_tape.

Page 1 - (list_tapes.asp) just needs to create a dropdown populated from tbl_tape. I am familiar with how to do this part, so you can skip all of the table set up and SQL statements. This will produce a field called "tape_id". But I can't work out how to retrieve this value from the dropdown.
Then ideally, each item in the dropdown is a hyperlink to the next page, which is passed the tape_id. So you press the relevant tape ID in the dropdown and it then goes to Page 2. So from memory, it will need a hyperlink of "list_files.asp?file_id = 3"

Page 2 - (list_files.asp) just need to list all of the video files for the value of tape_id sent from Page 1. Again I can do all of the SQL side of this, I just need to know how Page 2 references the value sent to it, which will be fk_tape
0
I am trying to utilize this piece of classic asp code and am getting errors:
<a href='javascript:delay(Update.asp?c=" & request.QueryString("c") & "&g=" & request.QueryString("g") & "')>

Open in new window

I only get errors when request.QueryString("g") contains a space:

Invalid left-hand side in assignment

Below is the function:
<script>
	function delay (URL) {
	setTimeout( function() { window.location = URL }, 500 );
	}
</script>

Open in new window


Thoughts?
0
I'd like to remove quotation marks from the "username" field before it is submitted.
Can this be done with JavaScript ?
0
I have a simple stored procedure which generates insert statements, and I want to know how to execute them automatically.

I am calling this stored procedure from a button on a Classic ASP page., which is the reason for wanting the INSERT statements to be executed after they are created.

In its simplest form,  here is the statement that generates the INSERT statements :

SELECT 'INSERT INTO DEV_Test (''' + txtSchoolID + ''', '''', '''', '''', '''' )' FROM DEV_Test2

Open in new window


… and this is what is produced :

INSERT INTO DEV_Test ('150721346050', '', '', '', '' )
INSERT INTO DEV_Test ('3456407213', '', '', '', '' )
INSERT INTO DEV_Test ('3721313250', '', '', '', '' )
INSERT INTO DEV_Test ('3721388839', '', '', '', '' )

Open in new window


… and I want the stored procedure to execute these statements.

Can anyone help?

Thank you

Jim
0
Exploring SQL Server 2016: Fundamentals
LVL 13
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

I installed parallels in a MacOS and then installed Windows 10.
We run a simple ClassicASP Application on the local IIS for development purposes.  It uses a few third party plugins.

We have the exact same configuration on another computer and it works just fine there, but on this install of Windows 10 when we try to use any of the plugins I get the following error:

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 

Open in new window

0
I am trying to work with Thread.CurrentPrincipal and need some help with that. Never used that before so any help will be helpful.

this is what i have so far.

            interface IAmSomething
            {
                  bool something(string role);
            }

public async Task<IActionResult> Index()

{
var haveRole= Thread.CurrentPrincipal as IAmSomething;

if (haveRole.something("some_string_value"))
{
}

I just need to test for now by hardcoding some values so what should i do in order for the if statement to work. as expected if statement is throwing a null exception .
0
Hi all, I am lost to how to make this work... or to describe it

the code:
<%
Set PackageOption=oConn.Execute("SELECT * FROM enq_items WHERE land_ID=1251 AND item_type=35")
%>
<td width=10% align=center rowspan=2><input type=hidden name=itemID value=5280><select name=packageID>
<%
Do Until PackageOption.EOF
%>
<option><%=PackageOption("item_ID")%></option>
<%
PackageOption.MoveNext
Loop
%>
</select><br><input type=submit name=package value='Add'></td>
<%

Open in new window

Submit Code:
oConn.Execute("UPDATE enq_items SET item_package="&Request.Form("packageID")&" WHERE item_ID="&Request.Form("itemID"))

Open in new window

error:
UPDATE enq_items SET item_package=5434, 5434, 5434, 5434, 5434, 5434, 5434, 5434 WHERE item_ID=5280, 5279, 5281, 5283, 5282, 5284, 5289, 5285
Microsoft JET Database Engine error '80040e14'

Syntax error in UPDATE statement.

/process.asp, line 955

Open in new window


As you can see its grabbing multiple packageIDs & itemIDs, how do i get it to grab just 1 of each?
0
This is not really a problem - yet. It is merely me trying to understand how to secure my code from sql injection. I'm using classic asp as it's all I know.

As far as I understand using stored procedures within my mysql database and then  calling these procedures would be the way forward. I'd like to get this working.
I was directed towards this web-page in an earlier question: https://www.mikesdotnetting.com/article/5/saved-parameter-queries-with-ms-access-and-asp

However this concerns an MS access database, and I can't get it to work in my mysql database (for obvious reasons I guess).

Let's assume that I have table MyTable with the followong fields: Id (mediumint), GUID (varchar), Name (Text), DateInserted (Datetime), Comments (Text) (DateTime), Status (mediumint)

I need to read from, update, insert and delete in this table.
I would need to create stored procedures for this, right? I can't seem to find a way to do that using phpMydAdmin (which is what I got and will use, regardless). How would I create these procedures?

Remember that this has to work with classic asp.
Best regards
Michael
0
I'm using asp.net web forms and visual basic.

On my page i have a ASP Textbox.

I'm using the TextChanged event.

This is my code:

    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs)


        HiddenField_TextBox1Changed.Value = TextBox1.Text

    End Sub

So when I type some text in the textbox, the textchanged event is saving the value I typed in the textbox, to a hidden field.

What's the equivalent to the TextChanged event of a textbox using JavaScript instead of Visual Basic?
1
Hi everyone!

At my wits end here. I have this code:
<%
Dim UserIPAddress
UserIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If UserIPAddress = "" Then
  UserIPAddress = Request.ServerVariables("REMOTE_ADDR")
End If



  userNow = Session("Bruger")
  
  SQLStr = "SELECT * FROM USERDATABASE WHERE Bruger = '" &  userNow & "'"
  Set RSDatabase = DATABASE.Execute(SQLStr)
  UserId =  RSDatabase("UserId")
  Admin =  RSDatabase("Navn")

GUID = Request.querystring("GUID")


   '*** Find brugernavn & adgangskode
    SQLmaal = _
     " SELECT "				&_
	"  *     "			&_
	" FROM   "			&_
	"  DATABASE "			&_
"  WHERE "			&_
"  GUID = " & GUID & "  "	

   Set RSDatabase = DATABASE.Execute(SQLmaal)

   GUID = RSDatabase("GUID")
id = RSDatabase("Id")
   navn = RSDatabase("Navn")
   Lokale = RSDatabase("Lokale")
   Email = RSDatabase("Email")
   tlf = RSDatabase("tlf")
   udstyr = RSDatabase("Udstyr")
   filepath = RSDatabase("filepath")
   Beskrivelse = RSDatabase("Beskrivelse")
   Datomodtaget = RSDatabase("Datomodtaget")
   Datoafsluttet = RSDatabase("Datoafsluttet")
   Bemaerkninger = RSDatabase("bemaerkninger")
   Sagsnr = RSDatabase("Sagsnr")
   Lokation = RSDatabase("Lokation")    



      

If DateM <> "" Then
a = Year( DateM ) 

b = Month( DateM )
if CInt( b ) < 10 then b = "0" & b

c = Day( DateM )
if CInt( c ) < 10 then c = "0" & c

j = Hour( DateM )
if CInt( j ) < 10 then j = "0" & j

e = Minute( DateM )
if CInt( e ) < 10 then e = "0" & e

f = second( DateM )

Open in new window

0

ASP

81K

Solutions

31K

Contributors

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.