System.ArgumentException 不支持关键字 trustserver certificste怎么解决

System.ArgumentException 不支持关键字 trustserver certificste怎么解决
调试错误出现在 Conn=sqlconnection(connstr)

这个错误通常是由于连接字符串中存在语法错误导致的。在连接字符串中,不应该使用 "TrustServerCertificate" 和 "Certificate" 这两个关键字。

如果确实需要在连接 SQL Server 数据库时使用证书认证,可以使用以下连接字符串格式:

Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;Encrypt=True;TrustServerCertificate=False;
Certificate=<path-to-certificate>;

其中,Encrypt 参数指定使用 SSL 加密数据传输,TrustServerCertificate 参数指示是否信任服务器证书,Certificate 参数指定客户端证书的路径。