[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

Cannot get data into a recordset of an asp page

I am using MS SQL server with InterDev as an editor coding in html and asp.  I have a web-based application
which resides in a subdirectory of another web-based application.

So the directory looks like this:

RecognizeYourBestPerformers      folder
    RecognizeYourBestCustomers    folder

As you can see, the "RecognizeYourBestCustomers" web-based application is in  a subdirectory of "RecognizeYourBestPerformers".

The "RecognizeYourBestPerformers" web-based app works fine.
Theses applications uses a .udl for the path.  The .uld is suppose to have all of the path information inside of it to get to the
right server.

The "RecognizeYourBestPerformers" app points to the .uld.  The "RecognizeYourBestCustomers" app also points to the same .udl.

Here is some of my code:
<HTML>
<TITLE>Recognize Your Best Customers Log-in Screen </TITLE>

<BODY>

<FORM name=frmInput method="get" action="process.asp">
 
<TABLE>
        <TR>
                <TD align=right>User Name:</TD>
                <TD align=left>
                        <INPUT style="WIDTH: 100px" class=inptext name="txtUserName" id="txtUserName" type="text" > 
                </TD>
        </TR>
        <TR>
                <TD align=right >Password:</TD>
                <TD align=left ><INPUT style="WIDTH: 100px" class=inptext maxlength=6 id="txtPassWord" name="txtPassWord" type="password" ></TD>
        </TR>
</TABLE>

<TABLE width=40%>
        <TR>
                <TD align=center>
                        <INPUT class=button type=submit value=" Log-in " >
                </TD>
        </TR>
</TABLE>
</FORM>
</HTML>

The system is suppose to go to the "process.asp" page and verify passwords.  See the "Form" tag statement.  The system does go
to the "process.asp" page, but I cannot get data from the server about the user's name role and password.

I have the following code in the process.asp page.

dim strConn
strConn = "Recognize.udl"
       
        dim str_SQL, obj, rs
        dim strSID
        dim strUserName
        dim strPassWord
               
        strSID = session.SessionID
        strUserName = Request.Form("txtUserName")
        strPassWord = Request.Form("txtPassWord")
       
        str_SQL = "select * from tbls_users where (user_name = '" & strUserName & "') " & _
                                "and (role_password = '" & strPassWord & "')"
        set obj=Server.CreateObject("SQLInstructions.SQL")
       
''Note:  I use a SQLInstructions.SQL file to create a Server Object.  I then use this object to execute the SQL statement
'to the server.  

        set rs = obj.execute(str_SQL,strConn)
       
       
        if not rs.eof then  'If there are any records in the users table with a user name and password then proceed.
               
                'Set session variables
                session("strSessionID") = strSID
                session("strUserName")= strUserName
                session("strJudge")=rs("Judge")
                session.Timeout = 60
               
                if rs("judge") = "fulltime" or rs("judge")="parttime" then
                        Response.Redirect "ProgramAdmin.asp"
                else
                        Response.Redirect "LoginScreen.asp"
                end if
               
        else 'If there are no records that match the user name and password then go back to the LoginScreen.
                Response.Redirect "LoginScreen.asp"
    end if
   
    rs.close
%>
 

PROBLEM: I cannot get data from the recordset to determine if the user should be directed to the next page or be redirected
back to the same page.  I tried "response.write rs("Judge")".  That does not work.

Any comments from anyone as to why data in not being populated into the recordset of the "process.asp" page.  The first web-based
application works fine.  Is it possible that subdirectories why have something to do with it?


Thanks
The Firebird
0
BirdsOfFire1
Asked:
BirdsOfFire1
  • 2
  • 2
  • 2
1 Solution
 
raj3060Commented:
Try to use:
Response.Write(rs("Judge"))

Keep more write statements to debug the problem.

**If you get page not found error then it could be directory problem. My guess is that you are not getting recordset. Best way to figure out is keep some srite statements and figure out where you have the problem.
0
 
raj3060Commented:
Another thing I noticed: Use this instead
Response.Redirect("ProgramAdmin.asp")
Response.Redirect ("LoginScreen.asp")
0
 
BirdsOfFire1Author Commented:
To:  raj3060

This statement does not work in the process.asp page:

alert ("This is a test")

I will try this:

Response.Write(rs("Judge"))


Thanks
The Firebird


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
eyeh8uCommented:
Personaly, I use ADODB to connect, I find it much easier to work with.

str_SQL = "select * from tbls_users where (user_name = '" & strUserName & "') " & _
                                "and (role_password = '" & strPassWord & "')"

Set obj = Server.CreateObject("ADODB.Connection")
obj.Connect Application("ConnectionString")
Set comm = Server.CreateObject("ADODB.Command")
Comm.ActiveConnection = obj
Set RS = Server.CreateObject("ADODB.Recordset")

Comm.CommandText = str_SQL

RS.Open Comm

If Not RS.EOF Then
...

You define a connection string typicaly in a global.asa file in the application_onstart event as follows:

Application("ConnectionString") = "your oledb init string from your .udl file"

Since both of your applications point to the same .udl, then you can probably use one global.asa with one connection string.
0
 
BirdsOfFire1Author Commented:
To:  eyeh8u

Below is the connection string that is in the .udl:

"provider=sqloledb;server=dbMainServer;initial catalog=Sales;trusted_connection=yes"

1.  Would you place this connect string information in your code to give me an idea of the syntax.

2.  Also, should I define "Comm"?:
     Dim  comm


Thanks
The Firebird
0
 
eyeh8uCommented:
Global.asa goes in the docroot of your web site. If you have a virtual directory, it will need it's own copy of global.asa in it's docroot.

Database.asp and closedatabase.asp go in the root of your web server. The command:

<!--#include virtual="/database.asp"-->

Will include it in your page scope, you'd have this in every page that did database operations to provide you with an open, connected database object, a command object and a recordset object to do your database operations with.

Any page that includes it should include closedatabase.asp to clean up your objects. You should always DIM every variable you use, and use Option Explicit to make ASP REQUIRE a variable to be declared prior to use (which prevents you ever having errors like:

<%
Dim mynumber
mynumber = 1
mynumber = mynubmer + 1
Response.Write mynumber ' prints 1, when you might have wanted 2...
%>

Option Explicit will cause ASP to throw an error on the sumation line of "Variable not declared mynubmer".

--- global.asa ----
<script language="VBScript" runat="Server">
sub application_onstart()
  ' application wide setting for database location:
  application("connectionstring") = "provider=sqloledb;server=dbMainServer;initial catalog=Sales;trusted_connection=yes"
end sub
</script>
--- end global.asa ---

--- database.asp ---
<%
' Define ADODB Objects:
Dim objConn, objComm, objRS
' Create ADODB Objects
Set objConn = Server.CreateObject("ADODB.Connection")
Set objComm = Server.CreateObject("ADODB.Command")
Set objRS = Server.CreateObject("ADODB.Recordset")

' Open a connection, and assign it to the command object
objConn.Open Application("ConnectionString")
objComm.ActiveConnection = objConn
%>
--- end database.asp ---

--- closedatabase.asp ---
<%
Set objRS = Nothing
Set objComm = Nothing
Set objConn = Nothing
%>
-- closedatabase.asp ---

--- somefile.asp ---
<%@ LANGUAGE=VBScript%>
<%
Option Explicit
%>
<!--#include virtual="/database.asp"-->
<%
dim str_SQLdim strSID
dim strUserName
dim strPassWord
               
strSID = session.SessionID
strUserName = Request.Form("txtUserName")
strPassWord = Request.Form("txtPassWord")

str_SQL =  "select * from tbls_users where (user_name = '" & strUserName & "') " & _
                                "and (role_password = '" & strPassWord & "')"

objComm.CommandText = str_SQL
objRS.Open Comm

if Not objRS.EOF Then
...
Else
...
End If

objRS.Close
%>
<!--#include virtual="/closedatabase.asp"-->
--- end somefile.asp ---
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now