ASP login form connecting SQL

Discussion in 'ASP General' started by tractng@gmail.com, Nov 22, 2005.

  1. Guest

    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 22, 2005
    #1
    1. Advertising

  2. McKirahan Guest

    <> wrote in message
    news:...
    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
     
    McKirahan, Nov 22, 2005
    #2
    1. Advertising

  3. Try this

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

    Richard Speiss

    <> wrote in message
    news:...
    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")


    %
     
    Richard Speiss, Nov 29, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Don
    Replies:
    0
    Views:
    456
  2. DavidADEW
    Replies:
    2
    Views:
    2,746
    DavidADEW
    Sep 1, 2006
  3. Sasquatch
    Replies:
    2
    Views:
    508
    Sasquatch
    Oct 4, 2006
  4. =?Utf-8?B?TmVpbCBQYWRkb2Nr?=

    Connecting to SQL 2000 database with SQL 2005 tools installed

    =?Utf-8?B?TmVpbCBQYWRkb2Nr?=, May 2, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    422
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    May 2, 2007
  5. manu
    Replies:
    1
    Views:
    837
    Evans
    Jul 20, 2008
Loading...

Share This Page