473,426 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

ASP login form connecting SQL

Guys,
I really need help with this. I need to creat a login page for the
website. Its an existing site that connects to SQL 7 with a local
user in the database called 'maya'. It was written by a former
employee
I want to be able to creat a table(called user) that has username &
password in that database. I will add the users manually.
Please help me with the codiing as I am a network person trying to do
programming.
Btw, I have done a simple login-on form in the past using ACCESS, but
not sure what to do in this instance as I need to allow the user in my
table (user) to have the correct permission to run.
Do I just use the local user called 'maya' to log onto the database
first , then check the users from the 'user' table?
Thanks in advance,
Tony
------ global.asa
file-----------------------------------------------------------------------*-----------------

<!-- (Global.asa) -->
<script language="vbscript" runat="server">
'Last database update to PRFormat on : 8/1/03 3:35pm
'************************************************* ********
'* Application Object Section *
'************************************************* ********
'************************************************* ****
'* Runs on application start *
'************************************************* ****
sub Application_OnStart()
'******** Declare Application Variables ************
Application("SQLdsn") = "Provider=SQLOLEDB; Data Source=EXCHANGE;
Initial Catalog=toandb; "
Application("SQLuser") = "User Id=maya;Password=maya;"
application("provider") = "SQLOLEDB"
application("datasource") = "EXCHANGE"
application("database") = "toandb"
Application("NumSession")=0
application("NumVisited")=0
end sub
'************************************************* ****
'* Runs on application end *
'************************************************* ****
sub Application_OnEnd()
end sub
'************************************************* ********
'* Session Object Section *
'************************************************* ********
'************************************************* ****
'* Runs on Session start *
'************************************************* ****
sub Session_OnStart()
'******** Declare Session Variables ************
session.CodePage=65001
application("NumSession") = application("NumSession") + 1
application("NumVisited") = application("NumVisited") + 1
'******** Perform application start procedures *****
GetSelectLists
GetFormLayout
Dim oConn, oRS
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
oConn.Open Application("SQLdsn") & Application("SQLuser")
set oRS = oConn.execute("SELECT aspVar FROM PRFormat")
temp = oRS.getstring(2,,"",",")
session("strFields") = "intDocID,intDocVer," & left(temp,
len(temp)-1)
oConn.close
oConn.open "Provider=SQLOLEDB; Data Source=EXCHANGE; Initial
Catalog=toandb;User Id=maya;Password=maya;"
set oRS = oConn.execute("select compound from compounds, status
where compounds.statusid = status.statusid and
status.EN_Name='Issued'")
session("aryCompounds") = oRS.GetRows
set oConn = nothing
end sub
'************************************************* ****
'* Runs on Session end *
'************************************************* ****
sub Session_OnEnd()
application("NumSession") = application("NumSession") - 1
end sub
'************************************************* ****
'* arrays for form select lists *
'************************************************* ****
sub GetSelectLists()
Dim oConn, oRS, strSQL
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
oConn.Open Application("SQLdsn") & Application("SQLuser")
strSQL = "Select ProdTypeID, EN_Name, Description from ProdType
ORDER BY EN_Name"
set oRS = oConn.execute(strSQL)
session("aryOrderTypes") = oRS.GetRows
strSQL = "SELECT id, EN_Name, Description FROM DimensionSpecs ORDER

BY EN_Name"
set oRS = oConn.execute(strSQL)
session("aryDimSpecs") = oRS.GetRows
strSQL = "SELECT id, EN_Name, Description FROM FlashSpecs ORDER BY
EN_Name"
set oRS = oConn.execute(strSQL)
session("aryFlashSpecs") = oRS.GetRows
strSQL = "SELECT id, EN_Name, Description FROM SurfaceSpecs ORDER
BY EN_Name"
set oRS = oConn.execute(strSQL)
session("arySurfaceSpecs") = oRS.GetRows
oRS.close
set oRS = nothing
oConn.close
set oConn = nothing
end sub
'************************************************* ****
'* arrays for storing the data field headers *
'************************************************* ****
sub GetFormLayout()
Dim oConn, oRS, strSQL, aryTemp()
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
oConn.Open Application("SQLdsn") & Application("SQLuser")
strSQL = "SELECT SectionOrder, EN_Name, CN_Name from
PR_Form_Sections ORDER BY SectionOrder"
set oRS = oConn.execute(strSQL)
'session("arySections") = oRS.GetRows
' .GetRows returns the rows/cols reversed for some reason.
temp = oRS.GetRows
maxrow = ubound(temp, 2)
maxcol = ubound(temp, 1)
'Invert the array
redim aryTemp(maxrow, maxcol)
for i = 0 to maxrow
for j = 0 to maxcol
aryTemp(i, j) = temp(j, i)
next
next
session("arySections") = aryTemp
strSQL = "SELECT SectionOrder, aspVar, EN_Name, CN_Name, inName,
inType, inSize,inLength, inBlur FROM viewFormLayout ORDER BY
SectionOrder, FieldOrder"
set oRS = oConn.execute(strSQL)
'session("aryFields") = oRS.GetRows
' .GetRows returns the rows/cols reversed for some reason.
temp = oRS.GetRows
maxrow = ubound(temp, 2)
maxcol = ubound(temp, 1)
'Invert the array
redim aryTemp(maxrow, maxcol)
for i = 0 to maxrow
for j = 0 to maxcol
aryTemp(i, j) = temp(j, i)
next
next
session("aryFields") = aryTemp
oRS.close
set oRS = nothing
oConn.close
set oConn = nothing
end sub
</script>
----------------- openSQL.asp
----------------------------------------------
<%
'************************************************* *******
'* SQL Connection *
'************************************************* *******
Dim oConn, oRS
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
'oConn.Open "Provider=SQLOLEDB; " & _
' "Data Source=EXCHANGE; " & _
' "Initial Catalog=toandb; " & _
' "User Id=maya; " & _
' "Password=maya;"
oConn.Provider = application("provider")
oConn.properties("Data Source").value = application("datasource")
oConn.properties("Initial Catalog").value = application("database")
'oConn.properties("Integrated Security").value = "SSPI"
'oConn.properties("Prompt").value = 1
'oConn.DefaultDatabase = application("database")
oConn.properties("User ID").value = "maya"
oConn.properties("Password").value = "maya"
oConn.open
'set oConn = session("oCn")
%

Nov 23 '05 #1
2 4489
<tr*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Guys,
I really need help with this. I need to creat a login page for the
website. Its an existing site that connects to SQL 7 with a local
user in the database called 'maya'. It was written by a former
employee

[snip]

http://www.aspfaq.com/5003
Nov 23 '05 #2
Try this

http://www.elated.com/tutorials/prog...rd_protection/

Richard Speiss

<tr*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Guys,
I really need help with this. I need to creat a login page for the
website. Its an existing site that connects to SQL 7 with a local
user in the database called 'maya'. It was written by a former
employee
I want to be able to creat a table(called user) that has username &
password in that database. I will add the users manually.
Please help me with the codiing as I am a network person trying to do
programming.
Btw, I have done a simple login-on form in the past using ACCESS, but
not sure what to do in this instance as I need to allow the user in my
table (user) to have the correct permission to run.
Do I just use the local user called 'maya' to log onto the database
first , then check the users from the 'user' table?
Thanks in advance,
Tony
------ global.asa
file-----------------------------------------------------------------------*-----------------

<!-- (Global.asa) -->
<script language="vbscript" runat="server">
'Last database update to PRFormat on : 8/1/03 3:35pm
'************************************************* ********
'* Application Object Section *
'************************************************* ********
'************************************************* ****
'* Runs on application start *
'************************************************* ****
sub Application_OnStart()
'******** Declare Application Variables ************
Application("SQLdsn") = "Provider=SQLOLEDB; Data Source=EXCHANGE;
Initial Catalog=toandb; "
Application("SQLuser") = "User Id=maya;Password=maya;"
application("provider") = "SQLOLEDB"
application("datasource") = "EXCHANGE"
application("database") = "toandb"
Application("NumSession")=0
application("NumVisited")=0
end sub
'************************************************* ****
'* Runs on application end *
'************************************************* ****
sub Application_OnEnd()
end sub
'************************************************* ********
'* Session Object Section *
'************************************************* ********
'************************************************* ****
'* Runs on Session start *
'************************************************* ****
sub Session_OnStart()
'******** Declare Session Variables ************
session.CodePage=65001
application("NumSession") = application("NumSession") + 1
application("NumVisited") = application("NumVisited") + 1
'******** Perform application start procedures *****
GetSelectLists
GetFormLayout
Dim oConn, oRS
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
oConn.Open Application("SQLdsn") & Application("SQLuser")
set oRS = oConn.execute("SELECT aspVar FROM PRFormat")
temp = oRS.getstring(2,,"",",")
session("strFields") = "intDocID,intDocVer," & left(temp,
len(temp)-1)
oConn.close
oConn.open "Provider=SQLOLEDB; Data Source=EXCHANGE; Initial
Catalog=toandb;User Id=maya;Password=maya;"
set oRS = oConn.execute("select compound from compounds, status
where compounds.statusid = status.statusid and
status.EN_Name='Issued'")
session("aryCompounds") = oRS.GetRows
set oConn = nothing
end sub
'************************************************* ****
'* Runs on Session end *
'************************************************* ****
sub Session_OnEnd()
application("NumSession") = application("NumSession") - 1
end sub
'************************************************* ****
'* arrays for form select lists *
'************************************************* ****
sub GetSelectLists()
Dim oConn, oRS, strSQL
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
oConn.Open Application("SQLdsn") & Application("SQLuser")
strSQL = "Select ProdTypeID, EN_Name, Description from ProdType
ORDER BY EN_Name"
set oRS = oConn.execute(strSQL)
session("aryOrderTypes") = oRS.GetRows
strSQL = "SELECT id, EN_Name, Description FROM DimensionSpecs ORDER

BY EN_Name"
set oRS = oConn.execute(strSQL)
session("aryDimSpecs") = oRS.GetRows
strSQL = "SELECT id, EN_Name, Description FROM FlashSpecs ORDER BY
EN_Name"
set oRS = oConn.execute(strSQL)
session("aryFlashSpecs") = oRS.GetRows
strSQL = "SELECT id, EN_Name, Description FROM SurfaceSpecs ORDER
BY EN_Name"
set oRS = oConn.execute(strSQL)
session("arySurfaceSpecs") = oRS.GetRows
oRS.close
set oRS = nothing
oConn.close
set oConn = nothing
end sub
'************************************************* ****
'* arrays for storing the data field headers *
'************************************************* ****
sub GetFormLayout()
Dim oConn, oRS, strSQL, aryTemp()
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
oConn.Open Application("SQLdsn") & Application("SQLuser")
strSQL = "SELECT SectionOrder, EN_Name, CN_Name from
PR_Form_Sections ORDER BY SectionOrder"
set oRS = oConn.execute(strSQL)
'session("arySections") = oRS.GetRows
' .GetRows returns the rows/cols reversed for some reason.
temp = oRS.GetRows
maxrow = ubound(temp, 2)
maxcol = ubound(temp, 1)
'Invert the array
redim aryTemp(maxrow, maxcol)
for i = 0 to maxrow
for j = 0 to maxcol
aryTemp(i, j) = temp(j, i)
next
next
session("arySections") = aryTemp
strSQL = "SELECT SectionOrder, aspVar, EN_Name, CN_Name, inName,
inType, inSize,inLength, inBlur FROM viewFormLayout ORDER BY
SectionOrder, FieldOrder"
set oRS = oConn.execute(strSQL)
'session("aryFields") = oRS.GetRows
' .GetRows returns the rows/cols reversed for some reason.
temp = oRS.GetRows
maxrow = ubound(temp, 2)
maxcol = ubound(temp, 1)
'Invert the array
redim aryTemp(maxrow, maxcol)
for i = 0 to maxrow
for j = 0 to maxcol
aryTemp(i, j) = temp(j, i)
next
next
session("aryFields") = aryTemp
oRS.close
set oRS = nothing
oConn.close
set oConn = nothing
end sub
</script>
----------------- openSQL.asp
----------------------------------------------
<%
'************************************************* *******
'* SQL Connection *
'************************************************* *******
Dim oConn, oRS
Set oConn=server.CreateObject("ADODB.Connection")
Set oRS=server.CreateObject("ADODB.Recordset")
'oConn.Open "Provider=SQLOLEDB; " & _
' "Data Source=EXCHANGE; " & _
' "Initial Catalog=toandb; " & _
' "User Id=maya; " & _
' "Password=maya;"
oConn.Provider = application("provider")
oConn.properties("Data Source").value = application("datasource")
oConn.properties("Initial Catalog").value = application("database")
'oConn.properties("Integrated Security").value = "SSPI"
'oConn.properties("Prompt").value = 1
'oConn.DefaultDatabase = application("database")
oConn.properties("User ID").value = "maya"
oConn.properties("Password").value = "maya"
oConn.open
'set oConn = session("oCn")
%
Nov 29 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Roberto Carabajal | last post by:
Hello: Please, I would appreciate any idea about this subject. I am working with Visual Studio 2005 and have made a Crystal Reports WebForm , with CrystalReportViewer and ReportSource Controls,...
3
by: Dam6 | last post by:
Okay... Using vb .net within DW MX2004, connecting to an access database: Background: I have created a simple login.aspx page that is supposed to re-direct to default.aspx using...
2
by: Assimalyst | last post by:
Hi, I am creating a website where i want to allow some webforms to be accessible to all users, and those in a subdirectory available only to authenticated users. I have created a script to...
0
by: Don | last post by:
When I attempt to access a SQL Server database from my ASP.NET 1.1 application I get the folllowing error: Login failed for user '(null)'. Reason: Not associated with a trusted SQL Server...
3
by: Randy Magruder | last post by:
Hi all, I hope someone here can diagnose what I'm seeing because I'm stumped. I have an asp.net 1.1 application with a login page. I have loaded up the Page_Load( ) with trace messages and...
6
by: Kat | last post by:
Every time I attempt to run a localhost website, it asks me for a login, as if I am not a user on the local machine. I am a user on the local machine, I am an admin on the local machine. I am not...
10
by: BLUE | last post by:
I'm using SQL Server 2005 Developer Edition on Windows XP SP2 with this setting: <add name="SqlServerTrustedConn" providerName="System.Data.SqlClient" connectionString="Data...
1
by: aj | last post by:
I'm a newbie w/ SQL Server 2005. We will be connecting to SQL Server 2005 via JDBC. We have made this work by using an SQL Server account, rather than an Active Directory (AD) account, even...
3
by: jerrydigital | last post by:
Hello, I have created a login.asp page which i have posted below. When I login into my site, it automatically takes me to the redirect page "index.html" which means that i entered the wrong login...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.