【问题标题】:vba unable to read timestamp field from oraclevba 无法从 oracle 读取时间戳字段
【发布时间】:2018-07-01 14:43:43
【问题描述】:

我在客户表中有一个查询“SELECT * FROM CUSTOMER”,当我尝试从 excel vba 检索数据时,我的数据类型之一是 TIMESTAMP(6),但出现错误。如果我使用 *,如何将时间戳转换为字符?

Set objConn = CreateObject("OracleInProcServer.XOraSession")
Set objDB = objConn.DbOpenDatabase("myDB", "UserID/Pass", 0)
strTBLQuery = "SELECT * FROM CUSTOMER"
Set rsTBLData = objDB.DbCreateDynaset(strTBLQuery, CInt(0))
Do While Not rsTBLData.EOF
    'I am getting "Object does not support this property or method" error for rsTBLData(i).value when it comes to date/timestamp field.
    strCellVal = rsTBLData(i).Value
Loop

【问题讨论】:

  • 错误信息是?
  • 时间戳是什么样子的?
  • 显示您的代码、您得到的确切错误以及您认为可能有用的任何其他内容(Oracle 版本、oracle 客户端版本、使用的确切驱动程序等)
  • 设置 objConn = CreateObject("OracleInProcServer.XOraSession") 设置 objDB = objConn.DbOpenDatabase("myDB", "UserID/Pass",0) strTBLQuery = "SELECT * FROM CUSTOMER" 设置 rsTBLData = objDB .DbCreateDynaset(strTBLQuery, cint(0)) Do While Not rsTBLData.EOF strCellVal = rsTBLData(i).value Loop 我收到 rsTBLData(i).value 的“对象不支持此属性或方法”错误。日期/时间戳字段。
  • 请自行编辑问题。不要将重要信息放在 cmets 中。

标签: sql excel vba oracle


【解决方案1】:

对于我认为你需要的时间戳值:

strCellVal = rsTBLData(i).Value.toDate

该字段的Value 属性是一个对象本身,它又具有方法...

http://k613.fd.cvut.cz/personal/jerabem1/14ndb/dokumentace_Oracle_11-2/win.112/e17727/advfeat.htm#OOFOL239

【讨论】:

  • 好的,谢谢,我最终使用了 java。我将检查 vbs 并发布我的结果。
猜你喜欢
  • 2020-10-27
  • 1970-01-01
  • 2018-10-24
  • 1970-01-01
  • 1970-01-01
  • 2018-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多