I am trying to program this thing where I clear one usernames chat history on Skype, so I have to use SQL Server to access main.db
in the Skype AppData
folder. However, I am receiving an error @ 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)"
Here's my code (TEXTBOX9 is the username of the participant):
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 database is on SQL Lite 3, hence you will need to use SQLite.NET.dll library.