ASP login form connecting SQL

T

tractng

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")


%
 
M

McKirahan

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
 
R

Richard Speiss

Try this

http://www.elated.com/tutorials/programming/asp/password_protection/

Richard Speiss

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")


%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top