c# - LocalDB MDF file property "Copy if newer" not working -
i developing application in visual studio 2012 .net framework 4.5 , using mdf file local db. problem here changes made data @ runtime not getting saved permanently. however, able retrieve data @ runtime save not displayed in server explorer. have set "copy output directory" property of mdf file "copy if newer" problem still exists. how solve it?
this connection string in application's app.config. had earlier tried seperate data set .xsd file no avail.
<connectionstrings> <add name="ea_logistics_control.properties.settings.logisticslocaldbcs" connectionstring="data source=(localdb)\v11.0 attachdbfilename=|datadirectory|\localdbs\logisticslocaldb.mdf;integrated security=true" providername="system.data.sqlclient" /> </connectionstrings>
some might suggest :
- use sqlexpress server instead of localdb or
- try connect localdb programmatically , replace bin\debug "folder_name\file_name.mdf"
but not actual solutions, alternative. can please explain happening here? , how solve it?
as requested, c# code is:
datetime dt = datetime.now; string cdate = dt.month + "/" + dt.day + "/" + dt.year; int norid = 0, neeid = 0, cfrom = 0, cto=0; sqlconnection scon = new sqlconnection(configurationmanager.connectionstrings["ea_logistics_control.properties.settings.logisticslocaldbcs"].connectionstring); if (scon.state == connectionstate.closed) scon.open(); sqlcommand scom = new sqlcommand("insert consignments values(@cno, @cdate, @invoiceno, @signorid, @signeeid, @travelfrom, @travelto, @packages, @contents, @vehicleno, @rate, @weight, @amount, '')", scon); scom.parameters.addwithvalue("cno", tb_ic_cn.text); scom.parameters.addwithvalue("cdate", cdate); scom.parameters.addwithvalue("invoiceno", tb_ic_o_inv.text); scom.parameters.addwithvalue("signorid", norid); scom.parameters.addwithvalue("signeeid", neeid); scom.parameters.addwithvalue("travelfrom", cfrom); scom.parameters.addwithvalue("travelto", cto); scom.parameters.addwithvalue("packages", tb_ic_num_o_pkgs.text); scom.parameters.addwithvalue("contents", tb_ic_desc.text); scom.parameters.addwithvalue("vehicleno", tb_ic_o_veh.text); scom.parameters.addwithvalue("rate", tb_ic_num_o_rate.text); scom.parameters.addwithvalue("weight", tb_ic_num_o_wt.text); scom.parameters.addwithvalue("amount", tb_ic_num_amt.text); int resrows = scom.executenonquery(); if (resrows > 0) { messagebox.show("new entry has been inserted."); }
it show me message box , have seen number of rows affected while debugging.
i received @samikuhmonen , @brendangreen on matter , solution was checking existence of data in mdf file of project folder through server explorer, should have done instead check mdf file in bin\debug folder data permanent. did creating new connection in server explorer output mdf file. wrongly assumed updated mdf file overwrite 1 in project folder supposed feature of "copy if newer". copies original file bin folder rather other way around. quite obviously, mdf fill empty fresh installation , after deployment, application on user side refer deployed file i.e. similar 1 in bin\debug.
Comments
Post a Comment