p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Classic ASP Basics (http://p2p.wrox.com/forumdisplay.php?f=61)
-   -   How to Change ASP.NET into Classic ASP? (http://p2p.wrox.com/showthread.php?t=73696)

GailCG April 1st, 2009 12:52 PM

How to Change ASP.NET into Classic ASP?
 
I need to convert a asp.net page back into classic ASP and I am running into problems in getting this accomplished. It is blowing up all over the place.
Help needed now!
Thank you.

I have:

Dim objRS
Set objRS = Server.CreateObject("ADODB.Recordset")

Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
[:confused:]
objConn.Open ConnectionString
cmd.Connection = sqlcon
cmd.CommandText = "sp_setapprole"
cmd.CommandType = CommandType.StoredProcedure

Dim rolename As SqlClient.SqlParameter = cmd.Parameters.Add("@rolename", SqlDbType.VarChar, 20)
rolename.Value = "PW1"
Dim password As SqlClient.SqlParameter = cmd.Parameters.Add("@password", SqlDbType.VarChar, 20)
password.Value = "PW2"

cn.Open()

cmd.ExecuteNonQuery()
Dim strUser As String
strUser = "DOMAIN\Users"
If (Roles.IsUserInRole(strUser)) Then
txtEmpID.Focus()
Else
Response.Redirect("http://home.asp")
End If

dparsons April 1st, 2009 01:09 PM

O.o Ok. Lots of problems here. First, for everything from your declaration of objRS to cmd.ExecuteNonQuery() go here about 3/4ths of the way down: http://www.15seconds.com/issue/000810.htm

Also you are referring to the same thing by 2 different names. You call objConn.Open then call cn.Open a little while later. Obviously only one of the objects refer to a connection and you only need ot open it once.

Second, since ASP is a weak typed language it has no support for string, int, double, etc during the declaration of the variable and, as such, all variables are defined as variants. So instead of Dim strUser as String you should only do Dim strUser.

ASP does not have a built-in membership/role provider so the call to Roles.IsUserInRole will need to be removed and you will have to write your own method to make this determination.

Lastly, you do not have access to TextBoxes like objects in classic asp. To set the focus of the textbox you are going to need to emit some javascript to achieve the desired result.

hth.
-Doug

Old Pedant April 22nd, 2009 06:04 PM

Well, that was a pretty irrelevant and useless post. Factually correct, but so what. Are you actually fishing for work??? That is, spamming us so you can get your URL in there?


All times are GMT -4. The time now is 10:11 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.