469,270 Members | 1,137 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,270 developers. It's quick & easy.

including activeX within ASP

Hi all,

I have some activeX code that I use to get the local computer name. (I don't
think this is possible using ASP from my research).

The rest of my code is ASP. I'd like to know how to pass the ActiveX
variable into my ASP script. My code is as follows. Thanks.

-----------------
activeX code: (I have this saved as activeX.asp which seems to work fine)

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
</script>
-----------------

ASP code:

<% @ Language="VBScript" %>

<% Option Explicit

'declare your variables
dim connection
dim sSQL,sConnString
dim Username

If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 access denied"
End If
Username=(Request.ServerVariables("LOGON_USER"))
'declare SQL statement that will query the database
'sSQL="INSERT INTO Log (FirstName, SurName) VALUES (Username, 'Wall')"

sSQL="INSERT INTO Log (Name) VALUES ('" & replace(Username,"'","''") & "')"
'define the connection string, specify database
' driver and the location of database
sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("ServerLog.mdb") & ";"

'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)

'execute the SQL
connection.execute(sSQL)

'check to see if there were any errors
If err.number=0 Then
response.write "the data was inserted successfully."
Else
response.write "there was a problem entering the data."
End If

'close the object and free up resources
Connection.Close
Set Connection = Nothing
%>
Jul 19 '05 #1
7 2560
I am assuming that the ActiveX component will be running in the browser and
not on the server. You will have to send a new request to the server after
you obtain the computer name.

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
this.location="yourasp.asp?computername=" & sComputername
</script>
--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Newbie" <Ne****@nospam.com> wrote in message
news:63H5c.3348$a95.386@newsfe1-win...
Hi all,

I have some activeX code that I use to get the local computer name. (I don't think this is possible using ASP from my research).

The rest of my code is ASP. I'd like to know how to pass the ActiveX
variable into my ASP script. My code is as follows. Thanks.

-----------------
activeX code: (I have this saved as activeX.asp which seems to work fine)

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
</script>
-----------------

ASP code:

<% @ Language="VBScript" %>

<% Option Explicit

'declare your variables
dim connection
dim sSQL,sConnString
dim Username

If Request.ServerVariables("LOGON_USER") = "" Then
Response.Status = "401 access denied"
End If
Username=(Request.ServerVariables("LOGON_USER"))
'declare SQL statement that will query the database
'sSQL="INSERT INTO Log (FirstName, SurName) VALUES (Username, 'Wall')"

sSQL="INSERT INTO Log (Name) VALUES ('" & replace(Username,"'","''") & "')"

'define the connection string, specify database
' driver and the location of database
sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("ServerLog.mdb") & ";"

'create an ADO connection object
Set connection = Server.CreateObject("ADODB.Connection")
'Open the connection to the database
connection.Open(sConnString)

'execute the SQL
connection.execute(sSQL)

'check to see if there were any errors
If err.number=0 Then
response.write "the data was inserted successfully."
Else
response.write "there was a problem entering the data."
End If

'close the object and free up resources
Connection.Close
Set Connection = Nothing
%>

Jul 19 '05 #2
Thanks for your reply.

The activeX will be running client side in their browser yes (because I need
it to grab their computer name and not the server's computer name).

My ASP page will also contain (when completed) a form for the user to fill
in. Once they click submit I want all the data gathered including the local
computer name to insert into the database.

I wanted the user just to run the ASP page, and for the ASP page to run the
activeX component behind the scenes.

Is this possible?

Cheers.

Mark Schupp wrote:

I am assuming that the ActiveX component will be running in the browser and not on the server. You will have to send a new request to the server after
you obtain the computer name.

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
this.location="yourasp.asp?computername=" & sComputername
</script>

Jul 19 '05 #3
No. You need two pages. The first is just an HTML page containing the
client-side code and the ActiveX Component , if there is one. The page may
be generated from ASP but there isn't any point in doing that. Just straight
HTML with the right client-side script is all that is needed.

The HTML page will do an autorefresh that calls the second (ASP) page and
passes the machinename to the ASP. The ASP page contains the Form and the
stored value for the machine name (session variable, hidden form field,
however you choose). The form is then submitted with the new data plus the
machine name.
--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
"Newbie" <Ne****@nospam.com> wrote in message
news:fFH5c.3540$a95.2468@newsfe1-win...
Thanks for your reply.

The activeX will be running client side in their browser yes (because I need it to grab their computer name and not the server's computer name).

My ASP page will also contain (when completed) a form for the user to fill
in. Once they click submit I want all the data gathered including the local computer name to insert into the database.

I wanted the user just to run the ASP page, and for the ASP page to run the activeX component behind the scenes.

Is this possible?

Cheers.

Mark Schupp wrote:

I am assuming that the ActiveX component will be running in the browser

and
not on the server. You will have to send a new request to the server after you obtain the computer name.

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
this.location="yourasp.asp?computername=" & sComputername
</script>


Jul 19 '05 #4
"Autorefresh" may not have been the best choice of words, but you should be
able to see the intent.
--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
"Phillip Windell" <@.> wrote in message
news:ek**************@TK2MSFTNGP09.phx.gbl...
No. You need two pages. The first is just an HTML page containing the
client-side code and the ActiveX Component , if there is one. The page may
be generated from ASP but there isn't any point in doing that. Just straight HTML with the right client-side script is all that is needed.

The HTML page will do an autorefresh that calls the second (ASP) page and
passes the machinename to the ASP. The ASP page contains the Form and the
stored value for the machine name (session variable, hidden form field,
however you choose). The form is then submitted with the new data plus the
machine name.
--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com
"Newbie" <Ne****@nospam.com> wrote in message
news:fFH5c.3540$a95.2468@newsfe1-win...
Thanks for your reply.

The activeX will be running client side in their browser yes (because I

need
it to grab their computer name and not the server's computer name).

My ASP page will also contain (when completed) a form for the user to fill
in. Once they click submit I want all the data gathered including the

local
computer name to insert into the database.

I wanted the user just to run the ASP page, and for the ASP page to run

the
activeX component behind the scenes.

Is this possible?

Cheers.

Mark Schupp wrote:

I am assuming that the ActiveX component will be running in the
browser and
not on the server. You will have to send a new request to the server

after you obtain the computer name.

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
this.location="yourasp.asp?computername=" & sComputername
</script>



Jul 19 '05 #5
put the activex component on the same page as the form.
include a hidden field in the form for the computername
use javascript to get the name from the activex component and put it in the
hidden form field
when the form is submitted the computer name will be available to the form
processing script.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Newbie" <Ne****@nospam.com> wrote in message
news:fFH5c.3540$a95.2468@newsfe1-win...
Thanks for your reply.

The activeX will be running client side in their browser yes (because I need it to grab their computer name and not the server's computer name).

My ASP page will also contain (when completed) a form for the user to fill
in. Once they click submit I want all the data gathered including the local computer name to insert into the database.

I wanted the user just to run the ASP page, and for the ASP page to run the activeX component behind the scenes.

Is this possible?

Cheers.

Mark Schupp wrote:

I am assuming that the ActiveX component will be running in the browser

and
not on the server. You will have to send a new request to the server after you obtain the computer name.

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
this.location="yourasp.asp?computername=" & sComputername
</script>


Jul 19 '05 #6
Thanks for the replies - sounds like I have a plan now.

As my username suggests it will take some research on my behalf to do this.
If you could point me in the right direction...especially for the javascript
bit then I'd appreciate it.

Thanks.
"Mark Schupp" <ms*****@ielearning.com> wrote in message
news:OL*************@TK2MSFTNGP12.phx.gbl...
put the activex component on the same page as the form.
include a hidden field in the form for the computername
use javascript to get the name from the activex component and put it in the hidden form field
when the form is submitted the computer name will be available to the form
processing script.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Newbie" <Ne****@nospam.com> wrote in message
news:fFH5c.3540$a95.2468@newsfe1-win...
Thanks for your reply.

The activeX will be running client side in their browser yes (because I

need
it to grab their computer name and not the server's computer name).

My ASP page will also contain (when completed) a form for the user to fill
in. Once they click submit I want all the data gathered including the

local
computer name to insert into the database.

I wanted the user just to run the ASP page, and for the ASP page to run

the
activeX component behind the scenes.

Is this possible?

Cheers.

Mark Schupp wrote:

I am assuming that the ActiveX component will be running in the
browser and
not on the server. You will have to send a new request to the server

after you obtain the computer name.

<Script language="vbscript">
Set oNetwork = CreateObject("WScript.Network")
sComputerName = oNetwork.ComputerName
this.location="yourasp.asp?computername=" & sComputername
</script>



Jul 19 '05 #7
Yes i'm having thesame problem. If anyone knows the answer plss tell us :)

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Rocio | last post: by
4 posts views Thread by Steve Lloyd | last post: by
1 post views Thread by Frank | last post: by
1 post views Thread by OfurGørn | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.