I am doing some calculation with the data set I take from my database. Null values give errors so I tried replacing null values with zeros(0). Here is the error I get,
ADODB.Recordset error ‘800a0cb3’
Current Recordset does not support
updating. This may be a limitation of
the provider, or of the selected
locktype.
Never seen it before. Here is my code.
If IsNull(objRevenueToday("REVENUE")) Then
objRevenueToday("REVENUE") = 0
End If
Metro Smurf
36.7k20 gold badges105 silver badges139 bronze badges
asked Jul 6, 2009 at 16:55
1
Your recordset appears to be read-only. There could be a number of reasons for this; you’re reading a view that contains a Group By clause, you don’t have permissions, etc.
answered Jul 6, 2009 at 17:14
Robert HarveyRobert Harvey
176k47 gold badges333 silver badges497 bronze badges
1
Using the syntax Set Recordset = Command.Execute always opens a read only cursor. What you need to do is open the cursor using the Recordset object. The Source parameter of the Open method is your Command object. This allows you to set the desired location and locktype.
Dim cmdProc as ADODB.Command
Dim rsData as ADODB.Recordset
Set cmdProc = New ADODB.Command
With cmdProc
Set .ActiveConnection = SomeConnection
.CommandType = adCmdStoredProc
.CommandText = "selCustomer"
' ... Create parameters
End With
Set rsData as New ADODB.Recordset
rsData.Open cmdProc,, adOpenStatic,adLockBatchOptimistic
'...Process recordset data.
answered Nov 24, 2016 at 5:48
user3069438user3069438
3213 silver badges2 bronze badges
1
Here is the solution:
If IsNull(objRevenueToday("REVENUE")) Then
RevenueToday = "0"
Else
RevenueToday = objRevenueToday("REVENUE")
End If
Not very ideal but fixed my error.
answered Jul 6, 2009 at 17:23
Assuming SQL Server (although similar techniques available in other DBs.
Change the query so that is will not return nulls in records. For example in the T-SQL
SELECT ISNULL(REVENUE, 0), .... FROM ....
answered Jul 6, 2009 at 20:39
AnthonyWJonesAnthonyWJones
186k35 gold badges232 silver badges305 bronze badges
Change the settings as below. It force the client side cursor…It worked for me
set pagedlistrs=CreateObject("adodb.recordset")
pagedlistrs.cursorlocation = 3 ' adUseClientpagedlistrs
pagedlistrs.Open SQL, objConn, 3,3,1
answered Dec 9, 2015 at 7:41
METALHEADMETALHEAD
2,6543 gold badges21 silver badges33 bronze badges
|
Lmstr 1 / 1 / 1 Регистрация: 21.03.2019 Сообщений: 14 |
||||
|
1 |
||||
|
07.07.2020, 19:43. Показов 2331. Ответов 5 Метки нет (Все метки)
Добрый день, уважаемые Знатоки. — Это вот сама ошибка
Миниатюры
__________________
0 |
|
828 / 459 / 79 Регистрация: 18.05.2016 Сообщений: 1,229 Записей в блоге: 4 |
|
|
08.07.2020, 07:42 |
2 |
|
Command.CommandText = «TAG:R,71,’0000-00-00 00:00:00.000′,’0000-00-00 00:01:00.000′» это что за команда такая?
0 |
|
1 / 1 / 1 Регистрация: 21.03.2019 Сообщений: 14 |
|
|
08.07.2020, 09:45 [ТС] |
3 |
|
Но ведь и провайдер особенный… Provider =WinCCOLEDBProvider.1;Catalog=CC_V_SERVER_19_06_26 _19_17_42 Миниатюры
0 |
|
amd48 828 / 459 / 79 Регистрация: 18.05.2016 Сообщений: 1,229 Записей в блоге: 4 |
||||||||
|
08.07.2020, 13:14 |
4 |
|||||||
|
свой код на форуме оформляйте тегами VB, а то прокляну на другом форуме нашёл, как с этим работают в дельфях.
а дальше уже работать с обычным рекордсетом Добавлено через 1 час 3 минуты
1 |
|
1 / 1 / 1 Регистрация: 21.03.2019 Сообщений: 14 |
|
|
08.07.2020, 21:04 [ТС] |
5 |
|
Спасибо, большое. Оказывается еще нужно установить ConnectivityPack или DataMonitor дополнительно к WinCC иначе никак не прицепиться к базе. Подсмотрел по ссылке: https://youtu.be/ePTPngU8rDw Не сильно часто бываю на форумах, — сильно криминально, если тегами не выделен код? ) Для чего вообще его выделять?
0 |
|
amd48 828 / 459 / 79 Регистрация: 18.05.2016 Сообщений: 1,229 Записей в блоге: 4 |
||||
|
09.07.2020, 12:09 |
6 |
|||
|
Для чего вообще его выделять? Чтоб собеседникам было проще его читать. Во-первых он раскрашивается примерно рядом со стилем среды разработки. Во-вторых сохраняются все отступы (если они были) — проще читать блоки циклов, логики и всего такого. В третьих в обсуждении можно сослаться на строчку кода по номеру, чтоб не цитировать весь код. В четвёртых есть кнопка «выделить код», чтоб в два клика скопировать его в буфер. Вобщем всё для вас — пользуйтесь Добавлено через 2 часа 28 минут
. Заменилось на
1 |
Forum Rules |
|
I am trying to anticapate errors so I can workaround potiential problems. However the following routine only produces an error every other time.
anybody know how or why?
First Execute: Errors
Second Execute: No Errors
Third Execute: Errors
Fourth Execute: No Errors
.
.
.
and so on.
This is what I am wanting a solution for:
I have two users, both using a identical recordset.
The first user to save the data back to the database wins. .UpdateBatch
Any other user has to resync the recordset or an error is to occur.
Of course, this only applies to the users that have obtained a recordset since the last update.
Any pointers?
_____________________________________________________________________________________________________________________________________________________
Public Sub Test()
‘ THE CODE
On Error GoTo Err_Handler
Dim RST1 as New ADODB.Recordset
Dim RST2 as New ADODB.Recordset
‘ Both RST1 & RST2 excutes the same command
Set RST1 = … ‘ LOCKTYPE —> adLockBatchOptimistic
Set RST2 = … ‘ CursorType —> adUseClient
‘ CursorLocation —> adOpenStatic
‘ CommandType —> adCmdStoredProc
‘ ActiveConnection —> CurrentProject.Connection
‘ RST1 & RST2 Recordcount > 10
RST1.MoveFirst
RST2.MoveFirst
RST2.MoveNext
RST1(«<Field1>»).Value = «<Value1>»
RST2(«<Field1>»).Value = «<value2>»
RST2.MoveFirst
RST1.UpdateBatch
RST2(«<Field1>»).Value = «<Value3>»
‘ The next line is where the error occurs.
RST2.UpdateBatch
Finish:
RST1.Close
RST2.Close
Set RST1 = Nothing
Set Rst2 = Nothing
Exit Sub
Err_Handler:
MsgBox Err.Number & » —> » & Err.Source & VbCrLf & Err.Description,vbOKOnly,»Error!»
Debug.Print RST1.Status ‘ Returns 8
Debug.Print RST2.Status ‘ Returns 2050
Resume Finish
End Sub
_____________________________________________________________________________________________________________________________________________________
_____________________________________________________________________________________________________________________________________________________
ERR OBJECT RETURNS:
_____________________________________________________________________________________________________________________________________________________
Err.Number —> -2147217887
Err.Number-VbObjectError —> 3617
Err.Source —> Provider
Err.Description —> «Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.»
Err.HelpContext —> 1240640
Err.HelpFile —> «C:PROGRA~1COMMON~1MICROS~1VBAVBA61033VbLR6.chm»
Err.LastDllError —> 0
_____________________________________________________________________________________________________________________________________________________
_____________________________________________________________________________________________________________________________________________________
ADODB.Recordset.ActiveConnection.Errors & ADODB.Recordset.ActiveCommand.ActiveConnection.Errors
_____________________________________________________________________________________________________________________________________________________
ITEM 1: (1).
Description —> «One or more properties cannot be returned.»
HelpContext —> 0
HelpFile —> «»
NativeError —> 44
Number —> -2147217887
Source —> «MSDataShape»
SQLState —> «»
Item 2: (2).
Description —> «Provider does not support the property.»
HelpContext —> 1240640
HelpFile —> «»
NativeError —> -2147217887
Number —> -2147217887
Source —> «ADODB.Connection»
SQLState —> «»
_____________________________________________________________________________________________________________________________________________________
-
Moved by
Tuesday, August 11, 2009 2:56 AM
Unable to move thread -
Moved by
Tim Li
Tuesday, August 11, 2009 3:24 AM
off-topic (From:Visual Basic for Applications (VBA))
ADO Errors
ADO Errors are reported to your program as run-time errors. You can use the error-trapping mechanism of your programming language to trap and handle them. For example, in Visual Basic, use the On Error statement. In Visual J++, use a try-catch block. In Visual C++, it depends on the method you are using to access the ADO libraries. With #import, use a try-catch block. Otherwise, C++ programmers need to explicitly retrieve the error object by calling GetErrorInfo. The following Visual Basic sub procedure demonstrates trapping an ADO error:
' BeginErrorHandlingVB01
Private Sub Form_Load()
' Turn on error handling
On Error GoTo FormLoadError
'Open the database and the recordset for processing.
'
Dim strCnn As String
strCnn = "Provider='sqloledb';" & _
"Data Source='MySqlServer';" & _
"Initial Catalog='Northwind';Integrated Security='SSPI';"
' cnn is a Public Connection Object because
' it was defined WithEvents
Set cnn = New ADODB.Connection
cnn.Open strCnn
' The next line of code intentionally causes
' an error by trying to open a connection
' that has already been opened.
cnn.Open strCnn
' rst is a Public Recordset because it
' was defined WithEvents
Set rst = New ADODB.Recordset
rst.Open "Customers", cnn
Exit Sub
' Error handler
FormLoadError:
Dim strErr As String
Select Case Err
Case adErrObjectOpen
strErr = "Error #" & Err.Number & ": " & Err.Description & vbCrLf
strErr = strErr & "Error reported by: " & Err.Source & vbCrLf
strErr = strErr & "Help File: " & Err.HelpFile & vbCrLf
strErr = strErr & "Topic ID: " & Err.HelpContext
MsgBox strErr
Debug.Print strErr
Err.Clear
Resume Next
' If some other error occurs that
' has nothing to do with ADO, show
' the number and description and exit.
Case Else
strErr = "Error #" & Err.Number & ": " & Err.Description & vbCrLf
MsgBox strErr
Debug.Print strErr
Unload Me
End Select
End Sub
' EndErrorHandlingVB01
This Form_Load event procedure intentionally creates an error by trying to open the same Connection object twice. The second time the Open method is called, the error handler is activated. In this case the error is of type adErrObjectOpen, so the error handler displays the following message before resuming program execution:
Error #3705: Operation is not allowed when the object is open. Error reported by: ADODB.Connection Help File: E:WINNTHELPADO260.CHM Topic ID: 1003705
The error message includes each piece of information provided by the Visual Basic Err object except for the LastDLLError value, which does not apply here. The error number tells you which error has occurred. The description is useful in cases in which you do not want to handle the error yourself. You can simply pass it along to the user. Although you will usually want to use messages customized for your application, you cannot anticipate every error; the description gives some clue as to what went wrong. In the sample code, the error was reported by the Connection object. You will see the object’s type or programmatic ID here—not a variable name.
Note The Visual Basic Err object only contains information about the most recent error. The ADO Errors collection of the Connection object contains one Error object for each error raised by the most recent ADO operation. Use the Errors collection rather than the Err object to handle multiple errors. For more information about the Errors collection, see Provider Errors. However, if there is no valid Connection object, the Err object is the only source for information about ADO errors.
What kinds of operations are likely to cause ADO errors? Common ADO errors can involve opening an object such as a Connection or Recordset, attempting to update data, or calling a method or property that is not supported by your provider.
OLE DB errors can also be passed to your application as run-time errors in the Errors collection. For more information about OLE DB error numbers, see Chapter 16 of the OLE DB Programmer’s Reference.


ata Source=DESKTOP-RTNSLG8SQLEXPRESS»

