Error when I press the button (Cannot open the backup device) but the location where I transfer the database is correct. how to have access to other folder.. because the default backup of sql my code is working to the default backup of microsoft..
C:\Users\orly.simbulan\Desktop\extracted
this is in my form load
try
{
SqlConnectionconn = newSqlConnection(connection);
conn.Open();
string sql_query="SELECT name from sys.databases WHERE name='Site5'";
SqlCommand cmd= newSqlCommand(sql_query,conn);
SqlDataReaderdr = cmd.ExecuteReader();
while(dr.Read())
{
listBox1.Items.Add(dr[0].ToString());
}
conn.Close();
}
catch(Exceptionex)
{
MessageBox.Show(ex.ToString());
}
in my button1
SqlConnectionconnec=newSqlConnection(connection);
connec.Open();
//MessageBox.Show(listBox1.SelectedItem.ToString());
stringlocation=@"C:\Users\orly.simbulan\Desktop\extracted";
stringsql="BACKUPDATABASE["+listBox1.SelectedItem.ToString()+"]TODISK='"+location+"\\"+"Database"+"-"+DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss")+".bak'";
SqlCommandcmd=newSqlCommand(sql,connec);
cmd.ExecuteNonQuery();
connec.Close();
This is the error...