• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 422
  • Last Modified:

ASP Locktype error help

hello

i have a small application and i get this error when i try to add a record


Additional information: Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
0
Chris Jones
Asked:
Chris Jones
  • 13
  • 9
1 Solution
 
Chris JonesAuthor Commented:
i dont quite understand the links you posted here is my code maybe this will help
        If ErrorMessage.Text = "" Then
            Call localDBConnectionOpen()
            sqlstmt = "SELECT * FROM Alumni WHERE ID = '" & ID & "' "
            rs = DBRecordSetNewFast(ConnPortal, sqlstmt)
 
            If rs.EOF Then
                rs.AddNew()
                Call DBFieldUpdate(rs, "Name", NewName)
                Call DBFieldUpdate(rs, "Email", NewEmail)
                Call DBFieldUpdate(rs, "Phone", NewPhone)
                Call DBFieldUpdate(rs, "Address", NewAddress)
 
                rs.Update()
                ErrorMessage.Text = "Adloc acct '" & ID & " " & ID & "' added."
            Else
                ErrorMessage.Text = "    Adloc acct '" & ID & " already exists."
            End If
            rs = DBRecordSetDestroy(rs)
            Call localDBConnectionClose()
        End If

Open in new window

0
 
Chris JonesAuthor Commented:
here is my function with my locktype info in it
    Public Function DBRecordSetNew(ByRef conn As ADODB.Connection, ByRef sqlstmt As String) As Object
        Dim newrs As ADODB.Recordset
 
        newrs = New ADODB.Recordset
        newrs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        newrs.CursorLocation = ADODB.CursorLocationEnum.adUseServer
        DBDebugStartTime = DBGetTickCount()
        'Try
        DBAbortSqlStmt = sqlstmt
        DBAbortConn = conn.ConnectionString
        newrs.Open(sqlstmt, conn, , ADODB.LockTypeEnum.adLockOptimistic)
        'Catch ex As Exception
        '    DBException = ex.Message & " " & ex.Source & " " & ex.ToString
        'End Try
        DBRecordSetNew = newrs
        Call DBDebugLogSQL("New", sqlstmt)
    End Function

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Chris JonesAuthor Commented:
Hello are you still avalable nmarun:
0
 
nmarunCommented:
Yes, I am.. just caught with other things.

Have a look at this:
http://msdn.microsoft.com/en-us/library/ms680885(VS.85).aspx

and/or try the code below.

rsGuruData.AddNew
rsGuruData.Fields("FirstName") = strFirstName
rsGuruData.Fields("LastName") = strLastName
rsGuruData.Fields("Age") = intAge
rsGuruData.Update

Open in new window

0
 
Chris JonesAuthor Commented:
Hmm were do i post this it tells me its not declared
0
 
nmarunCommented:

      If ErrorMessage.Text = "" Then
            Call localDBConnectionOpen()
            sqlstmt = "SELECT * FROM Alumni WHERE ID = '" & ID & "' "
            rs = DBRecordSetNewFast(ConnPortal, sqlstmt)
 
            If rs.EOF Then
                rs.AddNew()
                rs.Fields("Name") = NewName
                rs.Fields("Email") = NewEmail
                rs.Fields("Phone") = NewPhone
                rs.Fields("Address") = NewAddress
                rs.Update()
                ErrorMessage.Text = "Adloc acct '" & ID & " " & ID & "' added."
            Else
                ErrorMessage.Text = "    Adloc acct '" & ID & " already exists."
            End If
            rs = DBRecordSetDestroy(rs)
            Call localDBConnectionClose()
        End If

Open in new window

0
 
Chris JonesAuthor Commented:
i get an error when i replace it here

                rs.Fields("Name") = NewName
                rs.Fields("Email") = NewEmail
                rs.Fields("Phone") = NewPhone
                rs.Fields("Address") = NewAddress

new code
rsGuruData.AddNew
                rsGuruData.Fields("Name") = NewName
                rsGuruData.Fields("Email") = NewEmail
                rsGuruData.Fields("Phone") = NewPhone
                rsGuruData.Fields("Address") = NewAddress
rsGuruData.Update

ERROR

not defined
rsGuruData
0
 
Chris JonesAuthor Commented:
the database is not geting updated is there any reason why ?
0
 
nmarunCommented:
I'm not sure why you are using that code when I posted the actual code for you:

      If ErrorMessage.Text = "" Then
            Call localDBConnectionOpen()
            sqlstmt = "SELECT * FROM Alumni WHERE ID = '" & ID & "' "
            rs = DBRecordSetNewFast(ConnPortal, sqlstmt)
 
            If rs.EOF Then
                rs.AddNew()
                rs.Fields("Name") = NewName
                rs.Fields("Email") = NewEmail
                rs.Fields("Phone") = NewPhone
                rs.Fields("Address") = NewAddress
                rs.Update()
                ErrorMessage.Text = "Adloc acct '" & ID & " " & ID & "' added."
            Else
                ErrorMessage.Text = "    Adloc acct '" & ID & " already exists."
            End If
            rs = DBRecordSetDestroy(rs)
            Call localDBConnectionClose()
        End If

Open in new window

0
 
Chris JonesAuthor Commented:
i get this error when i use the code posted above

Error      3      Property 'Item' is 'ReadOnly'.
0
 
Chris JonesAuthor Commented:
this code produces no error but does not update the database
       If ErrorMessage.Text = "" Then
            Call localDBConnectionOpen()
            sqlstmt = "SELECT * FROM Alumni WHERE ID = '" & ID & "' "
            rs = DBRecordSetNewFast(ConnPortal, sqlstmt)
 
            If rs.EOF Then
                rs.AddNew()
                Call DBFieldUpdate(rs, "Name", NewName)
                Call DBFieldUpdate(rs, "Email", NewEmail)
                Call DBFieldUpdate(rs, "Phone", NewPhone)
                Call DBFieldUpdate(rs, "Address", NewAddress)
 
                rs.Update()
                ErrorMessage.Text = "Adloc acct '" & ID & " " & ID & "' added."
            Else
                ErrorMessage.Text = "    Adloc acct '" & ID & " already exists."
            End If
            rs = DBRecordSetDestroy(rs)
            Call localDBConnectionClose()
        End If

Open in new window

0
 
nmarunCommented:
Firstly, what does DBFieldUpdate do? I'm not sure of its implementation. I'm not saying its wrong, but just that I'm not sure. You can directly say:
rs.Fields("Name") = NewName

Also, where does 'NewName' get its value from? I also do not see some line like:

NewName = 'some place where the new value comes from'.

0
 
Chris JonesAuthor Commented:
do you want me to display the code  it may be a lot

also sorry for the long delay have been out of town with no computer
0
 
nmarunCommented:
What datatype is rs?

rs = DBRecordSetNewFast(ConnPortal, sqlstmt)


0
 
Chris JonesAuthor Commented:
it calls a function tht reads each field  of the database from my SQL selection statment
0
 
nmarunCommented:
My question was what 'rs' was and not what DBRecordSetNewFast does.
0
 
Chris JonesAuthor Commented:
recordset is the ADODB connection that traverses through the records.sorry for the long delay i have had a computer meltdown but everythings fixed and i will be happy to continue reciveing the help for you
0
 
nmarunCommented:
blingtec, please have a look at the link below. There's an example that you can use:
http://msdn.microsoft.com/en-us/library/ms677536(VS.85).aspx
0
 
Chris JonesAuthor Commented:
function from the file that yu requested


    Public Function DBRecordSetNewFast(ByRef conn As ADODB.Connection, ByRef sqlstmt As String) As Object
        Dim newrs As ADODB.Recordset
 
        newrs = New ADODB.Recordset
        newrs.CursorType = ADODB.CursorTypeEnum.adOpenForwardOnly
        newrs.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        DBDebugStartTime = DBGetTickCount()
        'Try
        DBAbortSqlStmt = sqlstmt
        DBAbortConn = conn.ConnectionString
        newrs.Open(sqlstmt, conn)
        'Catch ex As Exception
        'DBException = ex.Message
        'End Try
        DBRecordSetNewFast = newrs
        Call DBDebugLogSQL("NewFast", sqlstmt)
    End Function

Open in new window

0
 
nmarunCommented:
blingtec, this is seeming to go way out of control. Is it imperative that you use ADODB for this project? If not, you can quite easily do all this with ADO.NET classes like SqlCommand, DataSet and DataReader. There are tons of articles online for you to achieve this.
0
 
Chris JonesAuthor Commented:
forced to close this question without an answer or account will be closed
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 13
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now