c# - Connecting to ODBC driver from azure function
问题描述
I am currently working on an azure function that connects to a odbc driver. I have one locally called 'Dobbe WMS productie' and i am using the following code to connect to it.
using(odbcConnection conn = new OdbcConnection("DSN=Dobbe WMS productie"))
{
conn.Open();
// performs some actions
conn.Close();
}
Locally this works just fine. Now I published this to azure and it is not working, as i expected. The problem is, I cant find anything to solve my issue. Is there anyone that can help me with this?
EDIT:
My full error message: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
I opened the ODBC-datasources on windows -> System-DSN -> add and then choose the postgresql ansi driver. Filled out the basics in the form and clicked on save
I have also tried Npgsl and got the following error: The remote certificate is invalid according to the validation procedure.
my connection string looks something like this: Server=address;Port=5432;Database=dbname;User Id=username;Password=password;SslMode=Require
解决方案
感谢@rene 的帮助,我设法让它与 NpgSQL 一起工作。在深入了解服务点经理后,我发现我必须做一件小事。它将连接字符串修改为如下内容:
Server=address;Port=5432;Database=dbname;User Id=username;Password=password;SslMode=Require;Trust Server Certificate=true
推荐阅读
- sql - 如何删除 SQL 表列中具有相同 Word 的其他行
- java - 如果达到某个值,如何将 for 循环内的布尔值设置为 true?
- javascript - 从对象中提取值
- servicestack - JSONB - 按索引更新数组值
- regex-group - 一种正则表达式,用于捕获由一个空格字符分隔的单词,并结合相反的捕获出现的多个空格字符
- html - 设置 CSS 悬停查询时,如何覆盖 CDN 派生的悬停规则?
- jmeter - JMeter - 已安装插件列表
- sql - SQL Server - 试图找出这个表的垃圾邮件
- sql - 根据日期差异在时间戳上对客户 ID 进行分区
- cmake - CMake:如何在启用语言之前测试编译器