c# - Sqlite insert overwriting record -
i trying create .net application storing information in sqlite file. issue running once sql command executed, there 1 record visible, if current row being overwritten.
table creation:
bool pathexist = directory.exists(appdatapath + "oncalldb.sqlite"); if (!pathexist) { sqliteconnection.createfile(appdatapath + "oncalldb.sqlite"); sqliteconnection dbnewconnection = new sqliteconnection("data source=" + appdatapath + "oncalldb.sqlite;version=3;"); dbnewconnection.open(); string sqltablecreation = "create table calls (id integer primary key, name varchar(30), ticket varchar(20), phone varchar(20), day varchar(20), start_time varchar(20), end_time varchar(20), raw_time varchar(20), weighted_time varchar(20), date datetime, notes varchar(255))"; sqlitecommand command = new sqlitecommand(sqltablecreation, dbnewconnection); command.executenonquery(); dbnewconnection.close(); }
insert statement:
sqlitecommand insertcommand = new sqlitecommand("insert calls ([name], [ticket], [phone], [day], [start_time], [end_time], [raw_time], [weighted_time], [date], [notes])"+ "values(@name, @ticket, @phone, @day, @start_time, @end_time, @raw_time, @weighted_time, @date, @notes)",connection); insertcommand.parameters.addwithvalue("@name", name); insertcommand.parameters.addwithvalue("@ticket", ticket); insertcommand.parameters.addwithvalue("@phone", phone); insertcommand.parameters.addwithvalue("@day", day); insertcommand.parameters.addwithvalue("@start_time", start_time); insertcommand.parameters.addwithvalue("@end_time", end_time); insertcommand.parameters.addwithvalue("@raw_time", raw_time); insertcommand.parameters.addwithvalue("@weighted_time", weighted_time); insertcommand.parameters.addwithvalue("@date", date); insertcommand.parameters.addwithvalue("@notes", notes); try { connection.open(); insertcommand.executenonquery(); connection.close(); } catch(exception ex) { throw new exception(ex.message); }
i have ran command manually sql file , inserts new row. when run above sqlite command, replaces row. far can tell. have looked @ file creation date , time , appears file being modified , not replaced.
the issue not sql statement. issue how file being created
Comments
Post a Comment