For Programmers: Free Programming Magazines  


Home > Archive > ASP > November 2005 > ASP login form connecting SQL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ASP login form connecting SQL
tractng@gmail.com

2005-11-22, 6:55 pm

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-----------------------------------------------------------------------=
=AD-----------------



<!-- (Global.asa) -->


<script language=3D"vbscript" runat=3D"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") =3D "Provider=3DSQLOLEDB; Data Source=3DEXCHANGE;
Initial Catalog=3Dtoandb; "
Application("SQLuser") =3D "User Id=3Dmaya;Password=3Dmaya;"


application("provider") =3D "SQLOLEDB"
application("datasource") =3D "EXCHANGE"
application("database") =3D "toandb"


Application("NumSession")=3D0
application("NumVisited")=3D0


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=3D65001
application("NumSession") =3D application("NumSession") + 1
application("NumVisited") =3D application("NumVisited") + 1


'******** Perform application start procedures *****
GetSelectLists


GetFormLayout


Dim oConn, oRS
Set oConn=3Dserver.CreateObject("ADODB.Connection")
Set oRS=3Dserver.CreateObject("ADODB.Recordset")


oConn.Open Application("SQLdsn") & Application("SQLuser")
set oRS =3D oConn.execute("SELECT aspVar FROM PRFormat")


temp =3D oRS.getstring(2,,"",",")
session("strFields") =3D "intDocID,intDocVer," & left(temp,
len(temp)-1)


oConn.close


oConn.open "Provider=3DSQLOLEDB; Data Source=3DEXCHANGE; Initial
Catalog=3Dtoandb;User Id=3Dmaya;Password=3Dmaya;"
set oRS =3D oConn.execute("select compound from compounds, status
where compounds.statusid =3D status.statusid and
status.EN_Name=3D'Issued'")
session("aryCompounds") =3D oRS.GetRows


set oConn =3D nothing
end sub


'***************************************
**************
'* Runs on Session end *
'***************************************
**************
sub Session_OnEnd()
application("NumSession") =3D application("NumSession") - 1
end sub


'***************************************
**************
'* arrays for form select lists *
'***************************************
**************
sub GetSelectLists()
Dim oConn, oRS, strSQL
Set oConn=3Dserver.CreateObject("ADODB.Connection")
Set oRS=3Dserver.CreateObject("ADODB.Recordset")


oConn.Open Application("SQLdsn") & Application("SQLuser")


strSQL =3D "Select ProdTypeID, EN_Name, Description from ProdType
ORDER BY EN_Name"
set oRS =3D oConn.execute(strSQL)
session("aryOrderTypes") =3D oRS.GetRows


strSQL =3D "SELECT id, EN_Name, Description FROM DimensionSpecs ORDER

BY EN_Name"
set oRS =3D oConn.execute(strSQL)
session("aryDimSpecs") =3D oRS.GetRows


strSQL =3D "SELECT id, EN_Name, Description FROM FlashSpecs ORDER BY
EN_Name"
set oRS =3D oConn.execute(strSQL)
session("aryFlashSpecs") =3D oRS.GetRows


strSQL =3D "SELECT id, EN_Name, Description FROM SurfaceSpecs ORDER
BY EN_Name"
set oRS =3D oConn.execute(strSQL)
session("arySurfaceSpecs") =3D oRS.GetRows


oRS.close
set oRS =3D nothing
oConn.close
set oConn =3D nothing
end sub


'***************************************
**************
'* arrays for storing the data field headers *
'***************************************
**************
sub GetFormLayout()
Dim oConn, oRS, strSQL, aryTemp()
Set oConn=3Dserver.CreateObject("ADODB.Connection")
Set oRS=3Dserver.CreateObject("ADODB.Recordset")


oConn.Open Application("SQLdsn") & Application("SQLuser")


strSQL =3D "SELECT SectionOrder, EN_Name, CN_Name from
PR_Form_Sections ORDER BY SectionOrder"
set oRS =3D oConn.execute(strSQL)
'session("arySections") =3D oRS.GetRows


' .GetRows returns the rows/cols reversed for some reason.
temp =3D oRS.GetRows
maxrow =3D ubound(temp, 2)
maxcol =3D ubound(temp, 1)


'Invert the array
redim aryTemp(maxrow, maxcol)
for i =3D 0 to maxrow
for j =3D 0 to maxcol
aryTemp(i, j) =3D temp(j, i)
next
next
session("arySections") =3D aryTemp


strSQL =3D "SELECT SectionOrder, aspVar, EN_Name, CN_Name, inName,
inType, inSize,inLength, inBlur FROM viewFormLayout ORDER BY
SectionOrder, FieldOrder"
set oRS =3D oConn.execute(strSQL)
'session("aryFields") =3D oRS.GetRows


' .GetRows returns the rows/cols reversed for some reason.
temp =3D oRS.GetRows
maxrow =3D ubound(temp, 2)
maxcol =3D ubound(temp, 1)


'Invert the array
redim aryTemp(maxrow, maxcol)
for i =3D 0 to maxrow
for j =3D 0 to maxcol
aryTemp(i, j) =3D temp(j, i)
next
next
session("aryFields") =3D aryTemp


oRS.close
set oRS =3D nothing


oConn.close
set oConn =3D nothing
end sub


</script>


----------------- openSQL.asp
----------------------------------------------


<%
'***************************************
*****************
'* SQL Connection *
'***************************************
*****************
Dim oConn, oRS
Set oConn=3Dserver.CreateObject("ADODB.Connection")
Set oRS=3Dserver.CreateObject("ADODB.Recordset")


'oConn.Open "Provider=3DSQLOLEDB; " & _
' "Data Source=3DEXCHANGE; " & _
' "Initial Catalog=3Dtoandb; " & _
' "User Id=3Dmaya; " & _
' "Password=3Dmaya;"


oConn.Provider =3D application("provider")
oConn.properties("Data Source").value =3D application("datasource")
oConn.properties("Initial Catalog").value =3D application("database")
'oConn.properties("Integrated Security").value =3D "SSPI"
'oConn.properties("Prompt").value =3D 1
'oConn.DefaultDatabase =3D application("database")
oConn.properties("User ID").value =3D "maya"
oConn.properties("Password").value =3D "maya"
oConn.open=20


'set oConn =3D session("oCn")=20


%

McKirahan

2005-11-22, 6:55 pm

<tractng@gmail.com> wrote in message
news:1132702623.254172.113220@f14g2000cwb.googlegroups.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


Richard Speiss

2005-11-28, 9:55 pm

Try this

http://www.elated.com/tutorials/pro...ord_protection/

Richard Speiss

<tractng@gmail.com> wrote in message
news:1132702623.254172.113220@f14g2000cwb.googlegroups.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")


%


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com