Re: [sqlite] INSERT is not committing from c#

2010-06-15 Thread Simon Slavin

On 15 Jun 2010, at 3:07pm, nmartin wrote:

> I have a C# from which I am trying to perform a COMMIT. The INSERT does not
> throw an error but no data is inserted.

What makes you think that no data is inserted ?  If you quit your program after 
those instructions and examine the database with the command-line tool, does it 
show the newly-inserted row ?

>{
>SQLiteTransaction liteTransaction =
> Connection.BeginTransaction();
>SQLiteCommand command = new
> SQLiteCommand(insert.BuildInsert(tableName, keyValuePairs), Connection);
>command.Transaction = liteTransaction;
>command.ExecuteNonQuery();
>liteTransaction.Commit();
>}
>catch (SQLiteException e)
>{
>//error
>connection.Close();
>}

That depends on how your library works.  I have no idea what, for example 
'.BuildInsert()' does because it's not part of SQLite, nor can I tell if you're 
using .Commit() properly.  You might want to ask about the above in a list 
where they understand whatever library 'SQLiteTransaction' is from.

> And Just and Explicit Commit:
> 
> INSERT INTO TestData
> (deepbreathing,usertechnique,guidedimagery,yoga,exercise,meditation,prayer,somethingelse,howoften,numtechniques,userreturn,chosentechnique,chosentechnique)VALUES
> ("true","I will try to use deep
> breathing.","false","true","false","false","true","true","When I'm
> stressed","1","true","deepbreathing","deepbreathing"); COMMIT;

Strings in SQLite are surrounded with single quotes, not double quotes.  And be 
careful of your apostrophe.  For testing purposes leave it out until you're 
sure your software works generally.

Also, you show a minor misunderstanding of how transactions work.  Some 
programmers omit all commands to do with transactions.  If SQLite finds it's 
doing a data-changing command without you having started a transaction first, 
it will handle that command as if it's in its own transaction.  In other words 
it will do

BEGIN; ; COMMIT

for you.  You would not need the extra COMMIT command because SQLite already 
took care of it.  On the other hand, had you explicitly declared a transaction 
by putting a BEGIN before your INSERT, then nothing would be COMMITted until 
your own explicit COMMIT command.

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] INSERT is not committing from c#

2010-06-15 Thread nmartin

I have a C# from which I am trying to perform a COMMIT. The INSERT does not
throw an error but no data is inserted. I have tried a couple ways of
COMMITTING:

try
{
SQLiteTransaction liteTransaction =
Connection.BeginTransaction();
SQLiteCommand command = new
SQLiteCommand(insert.BuildInsert(tableName, keyValuePairs), Connection);
command.Transaction = liteTransaction;
command.ExecuteNonQuery();
liteTransaction.Commit();
}
catch (SQLiteException e)
{
//error
connection.Close();
}

And Just and Explicit Commit:

INSERT INTO TestData
(deepbreathing,usertechnique,guidedimagery,yoga,exercise,meditation,prayer,somethingelse,howoften,numtechniques,userreturn,chosentechnique,chosentechnique)VALUES
("true","I will try to use deep
breathing.","false","true","false","false","true","true","When I'm
stressed","1","true","deepbreathing","deepbreathing"); COMMIT;


Can anyone helps?
-- 
View this message in context: 
http://old.nabble.com/INSERT-is-not-committing-from-c--tp28891789p28891789.html
Sent from the SQLite mailing list archive at Nabble.com.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users