GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Apr 20, 2014 3:14 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: SQLITE and GTK+ - Can't Get Entry text into SQL Command
PostPosted: Fri Oct 19, 2012 2:28 pm 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
Hello Everyone,

I am using sprintf() to combine my text entrys on my GTK Application to insert into a sqlite database. it connects just fine to the database but it won't insert the text from the entrys and the time. Any Suggestions?

Code:
   time_t t = time(0);
   
   rc = sqlite3_open("src/myprogramdatabse.db3", &db);

   char cmd[200];

   sprintf(cmd,"INSERT INTO os_basics VALUES (%s, %s, %s, %s, %s)",ctime(&t), gtk_entry_get_text(GTK_ENTRY(entry_os_name)), gtk_entry_get_text(GTK_ENTRY(entry_os_id)), "variable", gtk_entry_get_text(GTK_ENTRY(entry_os_version)));   
   
   if (rc == SQLITE_OK)
   {
      rc = sqlite3_exec(db, cmd, callback, 0, &zErrMsg);
   }


Thank You


Top
 Profile  
 
 Post subject: Re: SQLITE and GTK+ - Can't Get Entry text into SQL Command
PostPosted: Fri Oct 19, 2012 3:58 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

There is nothing wrong with the code you posted as far as I can tell (I just quickly read it through). Did you try simply printing text from entries and ctime() function?

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: SQLITE and GTK+ - Can't Get Entry text into SQL Command
PostPosted: Fri Oct 19, 2012 4:25 pm 
Offline
Familiar Face

Joined: Sat Mar 03, 2012 2:45 am
Posts: 18
If i printf cmd it prints the SQL Statement "INSERT INTO os_basics VALUES (%s, %s, %s, %s, %s)",ctime(&t), gtk_entry_get_text(GTK_ENTRY(entry_os_name)), gtk_entry_get_text(GTK_ENTRY(entry_os_id)), "variable", gtk_entry_get_text(GTK_ENTRY(entry_os_version))"

ctime(&t) prints correctly


Top
 Profile  
 
 Post subject: Re: SQLITE and GTK+ - Can't Get Entry text into SQL Command
PostPosted: Fri Oct 19, 2012 5:32 pm 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hi.

You're really not providing much information about your problem. Post print statement in it's entirety and complete result if you want to get any help, since it's impossible to tell what is happening in all those other calls.

Cheers,
Tadej


Top
 Profile  
 
 Post subject: Re: SQLITE and GTK+ - Can't Get Entry text into SQL Command
PostPosted: Sun Oct 21, 2012 12:35 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
The fact that something is going wrong at the sprintf or earlier stage indicates this has nothing to do with SQLite. As tadej says there doesn't seem to be anything wrong with your sprintf command (obviously printf cmd does not return a string with all the %s's as %s's - you've really been misinformative by saying this - what exactly was printed? did it end after the time statement? Was "variable printed"? If anything what was printed for the get_entry calls?).
It is likely that there is something going wrong with your entries in which case the error in the code won't lie in what you've given. Please give a wider sample of your code that covers everything that could be related to this problem (e.g. setting up the entries and the containers they are placed in. Variable declarations - where are they located - are they global or how are they passed around. Function declarations/signal connection etc.) so its source can be more readily determined.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group