如何在ASP.NET Core 6 Web API中连接HFSQL数据库并访问数据
背景
现有HFSQL数据库已和异地WINDEV桌面应用正常连接,计划迁移为基于ASP.NET Core 6 Web API及前端框架的Web应用。通过HFSQL Control Center可正常连接并管理数据库,但Web API项目无法与数据库对接。
尝试方案1:ODBC驱动连接
安装PCSOFT提供的ODBC驱动后,使用如下连接字符串:
"ConnectionStrings": { "DefaultConnection": "Driver={HFSQL};Server Name=;Server Port=4900;Database=;UId=;PWD=;" }
连接失败,报错信息如下:
ERROR [08001] The SQL code defining the <Date_Added> calculated item is incorrect.
Error in the SQL code of the expression.Unable to load C:\Program Files (x86)\Common Files\PC SOFT\28.0\ODBC\Win64x86\wd280cpl64.dll DLL
Error detected:WL.DateDuJour()<<<<
System error code: 126
System error message:
The specified module could not be found.Debugging information:
DLL qui provoque le chargement : WDVM
DLL a charger : wd280cpl64.dll
DLL chargee : C:\Program Files (x86)\Common Files\PC SOFT\28.0\ODBC\Win64x86\wd280cpl64.dll
Chemin des DLL : C:\Program Files (x86)\Common Files\PC SOFT\28.0\ODBC\Win64x86
Chemin de l'EXE :
手动放置该DLL文件后,API应用在连接时无报错直接崩溃。
尝试方案2:OLEDB驱动连接
使用PCSOFT提供的OLEDB驱动,连接字符串如下:
"OLEDBConnect": "Provider=PCSOFT.HFSQL;Data Source=***.***.com:4900;User ID=*****;Password=******;Initial Catalog=*****;"
应用同样崩溃,但该驱动连接其他数据库实例时工作正常。
内容的提问来源于stack exchange,提问作者Dinushe Jayasekera

