我正在尝试在Unity和SQL Server数据库之间建立连接,但是由于SSL加密,我目前无法建立连接。
这是错误:
这是我用来建立连接的代码
using System;
using System.Data;
using System.Data.SqlClient;
namespace DB.Services
{
public class DBServices
{
private const string _connectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=Players;Integrated Security=True;Trusted Connection=True";
private SqlConnection _db;
public string ConnectToDB()
{
_db = new SqlConnection(_connectionString);
_db.Open();
if (_db.State != ConnectionState.Open)
return "Connection failed";
var users = GetUsers();
return users;
}
private string GetUsers()
{
var query = "SELECT * FROM Player";
SqlDataAdapter cmd = new SqlDataAdapter(query, _db);
var result = cmd.SelectCommand.ExecuteNonQuery();
_db.Close();
return result.ToString();
}
}
}
我见过的每个其他问题都建议连接字符串具有“ Trusted Connection = True”。但是,我仍然收到SSL加密错误。
谁能告诉我我做错了什么以及我需要做些什么来解决它?