Groups | Blog | Home
all groups > inetserver asp db > november 2005 >

inetserver asp db : ASP login form connecting SQL



tractng NO[at]SPAM gmail.com
11/22/2005 3:35:05 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----------------------------------------------------------------------------------------


<!-- (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; " & _
PJones
11/27/2005 12:00:00 AM
check out www.aspprotect.com
or search www.aspin.com


[quoted text, click to view]
AddThis Social Bookmark Button