HarmonyOS鸿蒙Next ArkUI-X使用relationalStore.RdbStore出错

HarmonyOS鸿蒙Next ArkUI-X使用relationalStore.RdbStore出错

try {
  const STORE_CONFIG: relationalStore.StoreConfig = {
    name: "RdbTest.db",
    securityLevel: relationalStore.SecurityLevel.S1
  };
  showLog.log(TAG, `开始链接数据库`);
  const t = await relationalStore.getRdbStore(getContext(this), STORE_CONFIG)
  showLog.log(TAG, `链接成功`);
} catch (err) {
  const error = err as BusinessError;
  showLog.error(TAG, `Database initialization failed, code: ${error.code}, message: ${error.message}`);
  //return `数据库初始化失败: ${error.message}`;
}

安卓侧调试包错:[js_console_log.cpp(103)] code: undefined, message: Cannot read property SecurityLevel of undefined
🙏哪位大佬能帮帮忙。


更多关于HarmonyOS鸿蒙Next ArkUI-X使用relationalStore.RdbStore出错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

2 回复

我这样写securityLevel:1,通过了。但下一步又是undefined,心累。

code: undefined, message: Cannot read property `getRdbStore` of undefined

更多关于HarmonyOS鸿蒙Next ArkUI-X使用relationalStore.RdbStore出错的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS鸿蒙Next中使用ArkUI-X的relationalStore.RdbStore时出错,可能原因包括:

  1. 数据库未正确初始化;
  2. 表结构不匹配;
  3. SQL语句错误;
  4. 权限不足。

建议检查数据库初始化代码,确保表结构与SQL语句正确,并确认应用具备访问数据库的权限。

回到顶部