2015-09-08 2 views
0

Я пытаюсь запрограммировать эту вещь, когда я удаляю одну историю чатов в usernames в Skype, поэтому я должен использовать SQL Server для доступа к main.db в папке Skype AppData. Тем не менее, я получаю сообщение об ошибке @maindb.Open();:Ошибка при попытке подключения к базе данных SQL Server

"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); 
} 

ответ

2

базы данных Skype на SQL Lite 3, следовательно, вам нужно используйте библиотеку SQLite.NET.dll.

Example

+0

** Большое спасибо, ФИКСИРОВАННАЯ МОЯ ПРОБЛЕМА *** –