Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Connection object

    I have inherited the following code from an existing system login asp page in my company. I am connecting to the same database and have been told to use the same connection code from below because it works fine. Im unsure exactly which code to keep and which code to extract. A global.asa has been set up in my project so I don't need to worry about that. Can anyone help me please?
    <
    dim c
    cn = "
    if len(Request.form("submit1")) > 0 the

    Set dbcn = server.CreateObject("ADODB.Connection"
    set dbrs = server.CreateObject("ADODB.Recordset"

    dbcn.open Application ("connectionString"

    lsSQL = "SELECT * FROM Users WHERE UserName = '" & replace(Request.Form("UserName"),"'","'") & "' AND Password = '" & replace(Request.Form("Password"),"'","'") & "'
    response.write lsSQ
    dbrs.Open lsSQL, dbcn,

    if dbrs.RecordCount > 0 the
    'Succes
    cn = "Welcome " & dbrs ("FirstName"
    Session ("ValidUser") = "Yes
    Response.Cookies("UserName") = dbrs ("UserName"

    Response.Cookies("DeptID") = dbrs ("DeptID"
    'Response.write Session ("UserName")& "-"& Session("DeptID"
    'Response.en
    Response.Redirect("Logon.asp"
    els
    'Failur
    cn = "Error you are not a valid user!!
    Session ("ValidUser") = "No
    end i
    end i
    %>
    Sean Guest

  2. Similar Questions and Discussions

    1. Remote Object - connection time out
      I am using RemoteObject services as the communication protocol between my Flex Client and J2EE server (WebSphere). After sending a request from...
    2. CFOBJECT COM Object Connection Exception
      Hello, I?m trying to connect to a NT service with one built in EXE server using CFMX 6.1 This object is always running I just need to connect...
    3. Can remote object use jdbc connection pool?
      Hi, Can a remote object use a jdbc connection pool? Does it have access to the connection pools running on the application server? Thanks, ED
    4. Database Connection Object
      1. Check out the microsoft application blocks - data access - http://support.microsoft.com/default.aspx?scid=kb;en-us;829028 2. Check out the...
    5. holding a connection object across several ASP pages
      Hi. I am new to ASP. I need to create a "wizard" using a SQL 7 database that will display a few forms and collect data from the user. My initial...
  3. #2

    Default Re: Connection object

    > <%
    > dim cn
    > cn = ""
    > if len(Request.form("submit1")) > 0 then
    >
    > Set dbcn = server.CreateObject("ADODB.Connection")
    > set dbrs = server.CreateObject("ADODB.Recordset")
    >
    > dbcn.open Application ("connectionString")
    >
    Keep the above and you can alter your lsSQL var to run different SQL
    > lsSQL = "SELECT * FROM ...."
    > response.write lsSQL
    > dbrs.Open lsSQL, dbcn, 3
    >
    Now have code to process the results

    Only you should clear up after yourself too

    dbrs.Close
    set dbrs = nothing
    dbcn.close
    set dbcn = nothing


    Adrian Forbes [ASP MVP] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139