1 Reply Latest reply on Jul 6, 2007 8:49 AM by Chunick

    ADO database error

    Xposure Interactive Level 1
      I have issued a program using the ADO Xtra to a client on their LAN. It works fine under administrator rights but when someone from a workgroup uses the program it returns the following erro when trying to write to the database:
      Error: COM error:
      Code = 80040e4d
      Code meaning = IDispatch error #3149
      Source = Provider
      Description = Authentication failed
      Another database is accessed from a different program and works fine. Here is my code:
      global gNme, gDoB, gCpny, gDate, gPass, gScore, gValAttempts, gUserLevel, rec, gConnectionString, gNewbie, gLocation

      on startMovie
      member("status").text = ""
      member("name1").text = ""
      member("name2").text = ""
      member("day").text = ""
      member("month").text = ""
      member("year").text = ""
      member("company").text = ""
      if baFileExists( the moviePath & "\inf\databaseLocation.txt" ) = TRUE then
      myFile = new(Xtra "FileIO")
      filename = the moviePath & "\inf\databaseLocation.txt"
      openFile(myFile, filename, 0)
      gLocation = readFile(myFile)
      closeFile(myFile)
      myFile = 0
      else
      gLocation = the moviePath & "records\SafeWorkingRecords.mdb"
      end if
      gConnectionString= "Provider=Microsoft.Jet.OLEDB.4.0;Mode=Read|Write;Data Source=" & gLocation & "; Jet OLEDB:Database Password=dreadlock"
      gNme = ""
      gDoB = ""
      gCpny = ""
      gDate = ""
      gPass = FALSE
      gScore = 0
      gValAttempts = 0
      gUserLevel = "0000000000000000000000"
      gNewbie = 0
      end

      on record
      rec=CreateObject(xtra "ADOxtra",#Recordset)
      if objectP(rec) then
      else
      alert "Error:"&& rec.lastError
      end if
      getThis = "SELECT Id, name, dob, IDnumber, lastDate, pass, attempts, userLevel FROM SWP_Records WHERE name='" & gNme & "' AND dob='" &gDoB& "'"
      rec.Open(getThis,gConnectionString,rec.adOpenKeyset,rec.adLockPessimistic)
      if rec.succeeded then
      else
      alert "Error:" && rec.lastError
      end if
      if rec.fields["name"] = "" then
      newUser
      else
      gNme = rec.fields["name"]
      gDoB = rec.fields["dob"]
      gPass = rec.fields["pass"]
      gValAttempts = rec.fields["attempts"]
      gUserLevel = rec.fields["userLevel"]
      member("status").text = member("status").text & RETURN & "Name: " & gNme
      member("status").text = member("status").text & RETURN & "Date of birth: " & gDoB
      member("status").text = member("status").text & RETURN & "ID number/company: " & gCpny
      end if
      end

      --on updateName
      -- rst.fields["Name"] = gNme2
      -- rst.Update()
      -- member("status").text = member("status").text && RETURN & rst.fields["Name"]
      --end

      on newUser
      gNewbie = 1
      cnn=CreateObject(xtra"ADOxtra",#Connection)
      if objectP(cnn) then
      nothing
      else
      alert "Error:" && cnn.Errors
      end if
      cnn.Open(gConnectionString)
      if cnn.succeeded then
      nothing
      else
      alert "Error:" && cnn.Errors
      end if
      cnn.Execute("INSERT INTO SWP_Records (name, dob, IDnumber, pass, attempts, userlevel, lastDate) VALUES ('"&gNme&"', '"&gDoB&"', '"&gCpny&"', '"&gPass&"', '"&gValAttempts&"', '"&gUserLevel&"', '"&gDate&"')")
      if cnn.succeeded then
      cnn.Close()
      record
      else
      alert cnn.Errors
      cnn.Close()
      end if
      end

      on stopMovie
      rec.fields["name"] = gNme
      rec.fields["dob"] = gDoB
      rec.fields["IDnumber"] = gCpny
      rec.fields["pass"] = gPass
      rec.fields["attempts"] = gValAttempts
      rec.fields["userLevel"] = gUserLevel
      rec.fields["lastDate"] = the short date
      rec.Update()
      end
      A user is neither recovered from the database nor written to the database.
      Any help would be greatly appreciated.
      Kind regards,
        • 1. Re: ADO database error
          Chunick Level 3
          try using the runas command to run the application as the administrator... see if that works... you may either:
          1) set up user/pass fields in the application or an "options" MIAW where the administrator can securely enter his user/pass and then it gets written to an encrypted (and hidden, maybe) file where it's accessed on subsequent runs of the application. Use a stub to run the runas command to launch the app as the administrator.
          2) or you can try writing application information to the registry...

          either solution will require some further research as I'm not sure of the solution myself, just taking an educated guess.