problem with item placed by corinn martens

Results 1 to 2 of 2

Thread: problem with item placed by corinn martens

  1. #1 Guest

    Default problem with item placed by corinn martens

    Plaese someone!!!!<BR>Having problem with the database login script by corrin martens.<BR><BR><BR>I get the error that the script is looking for a object:<BR><BR>mistake:<BR>Runtime error Microsoft VBScript (0x800A01A8)<BR>Object wanted: &#039&#039<BR>/test_2/index2.asp, line 37<BR><BR>Here is the code:<BR><BR><BR><BR>&#060;%@LANGUAGE="VBSCRIPT"%& #062; <BR>&#060;% Option Explicit %&#062;<BR> <BR><BR>&#060;% Response.Buffer = true %&#062; <BR>&#060;%<BR> Session("DatabasePath") = "C:homepages est_2log.mdb"<BR> If Request.Form("btnLogin") = "Login" AND Request.Form("txtName") &#060;&#062; "" _<BR> AND Request.Form("txtPassword") &#060;&#062; "" Then<BR><BR> &#039-- Declare your variables<BR> Dim DataConnection, cmdDC, RecordSet<BR> Dim RecordToEdit, Updated, strUserName, strPassword<BR><BR> strUserName = Request.Form("txtName")<BR> strPassword = Request.Form("txtPassword")<BR><BR> &#039-- Create object and open database<BR> &#039-- Create object and open database<BR> Set DataConnection = Server.CreateObject("ADODB.Connection")<BR> DataConnection.Open "DRIVER={Microsoft Access driver (*.mdb)};" & _<BR> "DBQ=" & Session("DatabasePath") & ";"<BR><BR><BR>&#039-- default SQL<BR> Dim SQL <BR> SQL = "SELECT * FROM tblSecurity"<BR><BR> If Request.Form("txtName") &#060;&#062; "" Then <BR> SQL = "SELECT tblSecurity.* FROM tblSecurity " & _<BR> "WHERE tblSecurity.userID=&#039" & strUserName& _<BR> "&#039 AND tblSecurity.password =&#039" & strPassword & "&#039"<BR> End If<BR><BR><BR> cmdDC.ActiveConnection = DataConnection<BR> cmdDC.CommandText = SQL<BR> Set RecordSet = Server.CreateObject("ADODB.Recordset")<BR><BR><BR> &#039-- Cursor Type, Lock Type<BR> &#039-- ForwardOnly 0 - ReadOnly 1<BR> &#039-- KeySet 1 - Pessimistic 2<BR> &#039-- Dynamic 2 - Optimistic 3<BR> &#039-- Static 3 - BatchOptimistic 4<BR> RecordSet.Open cmdDC, , 0, 2<BR><BR> If Not RecordSet.EOF Then<BR> Dim struserLevel<BR> struserLevel = RecordSet.Fields("userLevel")<BR> Session("userLevel") = struserLevel<BR> Else<BR> &#039The user was not validated...<BR> &#039Take them to a page which tells them they were not validated...<BR> Response.Redirect "register.asp"<BR> End If<BR> End If<BR>%&#062;<BR><BR>

  2. #2 Guest

    Default RE: problem with item placed by corinn martens

    You have not indicated which line is line 37, but I beleive it is one of these 2 lines:<BR><BR>cmdDC.ActiveConnection = DataConnection<BR>cmdDC.CommandText = SQL<BR><BR>You obviously intended to create a Command object and execute it. Therefore somewhere before these lines you probably need to include the line<BR>Set cmdDC=server.createobject("ADODB.Command")<BR><BR> In your code you are trying to set properties of an object that you have not instantiated.<BR><BR>I do not know the finer details of command object, because I never use it and I cannot see why you would want to use it yourself. I would suggest the following for coding your script:<BR><BR>&#060;%<BR>DataConnection.Open "DRIVER={Microsoft Access driver (*.mdb)};" & "DBQ=" & Session("DatabasePath") & ";"<BR><BR>&#039-- default SQL<BR>Dim SQL <BR>SQL = "SELECT * FROM tblSecurity"<BR><BR>If Request.Form("txtName") &#060;&#062; "" Then <BR>SQL = "SELECT tblSecurity.* FROM tblSecurity " & _<BR>"WHERE tblSecurity.userID=&#039" & strUserName& _<BR>"&#039 AND tblSecurity.password =&#039" & strPassword & "&#039"<BR>End If<BR><BR><BR>Set RecordSet = Server.CreateObject("ADODB.Recordset")<BR>RecordSe t.Open SQL,DataConnection , 0, 2<BR><BR>%&#062;<BR>This makes the code a bit simpler. You count also just use the Execute method of the Connection to open your recordset, but the recordset.Open command provides more oprions.

Posting Permissions

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