Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    UK
    Posts
    23

    Red face Unanswered: Cannot open database requested in login...

    Hi,

    I am using ASP to connect to an MS SQL database. The script connects to the database OK and I can retrieve recordset data and add new rows without a problem.

    However, when I try to edit a recordset (using the recordset.update command), I get the following error:

    Cannot open database requested in login 'andthen_development'. Login fails.

    My first thought was that it must be a permissions problem, but that doesn't explain why I can view and add rows, but not edit. Any ideas?


    Thanks, Paul

  2. #2
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Cannot open database requested in login...

    did you try an "Update" command

    objCommand.ActiveConnection = objConnection objCommand.CommandText = "Update Table tbl set ..."
    Call objCommand.Execute


    just see if this works with your login

    or try updating with the QA and your login

  3. #3
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393

    Re: Cannot open database requested in login...

    then we'll see why the RecordSet.Update doesn't work

  4. #4
    Join Date
    Feb 2004
    Location
    UK
    Posts
    23
    Just tried an "UPDATE TABLE..." command directly and it works fine. However, I have an ASP include file that I use to handle all database functionality centrally. Included in this is the following function:

    Function editRow(sqlString, rowParameters)
    '#--- UPDATES AN EXISTING DATABASE ROW

    '#--- SET UP RECORDSET FOR EDITING A RECORD
    Set recordSet = Server.CreateObject("ADODB.RecordSet")
    recordSet.CursorLocation = adUseServer
    recordSet.CursorType = adOpenForwardOnly
    recordSet.LockType = adLockOptimistic

    recordSet.Open sqlString, connection, , ,adCmdText

    '#--- ITERATE THROUGH rowParameters TO UPDATE ITEM'S FIELDS
    Dim rowField
    For Each rowField In rowParameters
    recordSet(rowField) = rowParameters.Item(rowField)
    Next

    '#---UPDATE RECORDSET (UPDATE RECORD)
    recordSet.Update

    End Function

    The function accepts an SQL string to identify the row (e.g. "SELECT * FROM...") and a Dictionary object that contains keys relating to field names and values giving the new contents for the row.

    This produces an error on the recordset.Update line.


    Paul

  5. #5
    Join Date
    Nov 2003
    Location
    FRANCE
    Posts
    393
    maybe it's the cursor location
    or one of the option of the recordset

    Set recordSet = Server.CreateObject("ADODB.RecordSet")
    recordSet.CursorLocation = adUseServer
    recordSet.CursorType = adOpenForwardOnly
    recordSet.LockType = adLockOptimistic

Posting Permissions

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