c# - Failed to attach an auto-named database -


so have c# software save data database every time run program , try save data message, please help?

enter image description here

try {     sqlconnection cnn = new sqlconnection(@"data  source=.\sqlexpress;         attachdbfilename=c:\users\hp\documents\visual studio 2010\projects\bank_system\bank_system\bank_system.sdf;         integrated security=true;user instance=true");     cnn.open();     sqlcommand cmd1 =         new sqlcommand("insert user values('" +             textbox6.text + "','" + textbox1.text + "','" + textbox4.text + "'," +             textbox3.text + ",'" + textbox2.text +  "','" + textbox5.text + "')",            cnn);     sqldatareader dr1 = cmd1.executereader();     dr1.close();     messagebox.show(" record inserted ", " information inserted");     cnn.close(); } catch (sqlexception ex) {     messagebox.show(ex.message); } 

copy database bank_system.sdf in \bin\debug\ folder , change connection string :

sqlconnection cnn = new sqlconnection("data source=" +@".\sqlexpress;             attachdbfilename=bank_system.sdf;             integrated security=true;user instance=true"); 

it should worked, if error occurs, try execute app yourapp.exe located in \bin\debug\ folder


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -