简体   繁体   English

Excel VBA从设置为只读的Oracle数据库读取数据

[英]Excel vba to read data from a oracle database which was set to readonly

我正在尝试使用excel中的adodb连接对象从oracle读取数据。但是我收到一个错误“ oracle -160000数据库设置为只读访问权限”。请让我知道如何解决此问题。

Look at the recordset open method's LockType parameter and use adLockReadOnly. 查看记录集打开方法的LockType参数,然后使用adLockReadOnly。 I'm not familiar with Oracle. 我对Oracle不熟悉。 You may also need to CursorType parameter to adOpenForwardOnly. 您可能还需要将CursorType参数设置为adOpenForwardOnly。

Example: 例:

Dim lobjADOConnection As ADODB.Connection
Dim lobjADOData As ADODB.Recordset
Dim lstrSQL As String

Set lobjADOConnection = New ADODB.Connection
lobjADOConnection.Open ...

Set lobjADOData = New ADODB.Recordset

lstrSQL = "<your query here>"

lobjADOData.Open lstrSQL, lobjADOConnection, adOpenForwardOnly, adLockReadOnly '<===here
If Not lobjADOData.BOF Then
    lobjADOData.MoveFirst
    Do While Not lobjADOData.EOF
        DoEvents
        .
        .
        .

or if you just want to dump the data into a worksheet 或者如果您只想将数据转储到工作表中

Dim lobjTargetSheet As Worksheet

Set lobjTargetSheet = ThisWorkbook.Sheets("<SomeSheetName>")
With lobjTargetSheet
    .Select
    .Range("1:" & .UsedRange.Rows.count + 1).Delete xlUp
    .Range("A1").Select
    .Range("A1").CopyFromRecordset lobjADOData
End With

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel过滤数据库中的数据集 - Excel filtering data set from a database 如何从包含单引号的Oracle数据库中搜索数据 - How to search data from oracle database which contains single quote 如何从 python 中写入和读取 oracle 数据库中的 clob 类型数据? - How to write and read clob type data in oracle database from python? VBA中来自WEB的Excel数据库 - Excel database from WEB in VBA 将Excel数据表加载到Oracle数据库 - Load Excel data sheet to Oracle database 如何使用 VBA 使用来自其他 excel 文件的新数据覆盖数据库中的数据? - How to overwrite the data in database with new data coming from other excel files using VBA? 是否可以从远程Oracle数据库中读取CLOB? - Is it possible to read a CLOB from a remote Oracle database? 从数据库读取和返回数据的 Excel VBA 用户定义的 Function 并不总是有效。 为什么? - Excel VBA User Defined Function That Reads and Returns Data from a Database Doesn't Always Work. Why? 这将是使用Core Data(iOS)更新用户ReadOnly数据库的最佳方式 - Which will be the best way to update users ReadOnly database using Core Data (iOS) 从数据库或文件中读取数据源并基于 API 标识符,将数据保存在数据库中? 使用哪个工具? - Read datasource from a database or a file and based on API identifier, save data in the database? Which tool to use?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM