尝试连接到 SQL 服务器数据库时出错

Error when trying to connect to SQL Server database

我正在尝试编程这个东西,我在 Skype 上清除一个用户名的聊天记录,所以我必须使用 SQL 服务器访问 Skype AppData 文件夹中的 main.db。但是,我收到一个错误 @ maindb.Open();:

"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)"

这是我的代码(TEXTBOX9 是参与者的用户名):

if (warningcrash == DialogResult.Yes)
{
    for (i = 0; i < 50; i++)
    {
        skype.SendMessage(textBox9.Text, textBox10.Text);
    }

    string participant = textBox9.Text;
    database = Environment.GetEnvironmentVariable("APPDATA") + @"\Roaming\" + @"\Skype\" + skype.CurrentUserHandle + @"\main.db";

    Process[] proc = Process.GetProcessesByName("skype");
    proc[0].Kill();

    SqlConnection maindb = new SqlConnection("data source=" + database);

    SqlDataAdapter ad;
    DataTable dt = new DataTable();

    SqlCommand cmd;

    maindb.Open(); //error occurs here

    cmd = maindb.CreateCommand();
    cmd.CommandText = "delete from Messages Where dialog_partner = '" + participant + "'";
    ad = new SqlDataAdapter(cmd);
    ad.Fill(dt);
}

Skype 数据库在 SQL Lite 3 上,因此您需要使用 SQLite.NET.dll 库。

Example