Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » sql + editstring
sql + editstring [message #32347] Tue, 10 May 2011 15:48 Go to next message
begnur is currently offline  begnur
Messages: 6
Registered: May 2011
Location: Turkmenistan
Promising Member
how to pass WString from EditString to Sql and from Sql To EditString

for example (below exmaples are only for demonstration I need how to do this. and again characters are non ascii

EditString editstr
 String s = editstr->GetString()
// s contains "" , database contains p,q,r where p,q,r as string
Sql sql
sql * Select(p).From(databse).Where(q = s)

// clearing s string
s.Clear();
while(sql.Fetch())
   s.Append(sql[p]);

editstr->SetString(s);



Re: sql + editstring [message #32350 is a reply to message #32347] Tue, 10 May 2011 20:16 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 681
Registered: November 2008
Location: France
Contributor
Hi begnur,

you can use an 'SqlCtrls' object to achieve what you want.

You can do something like this:

SqlCtrls ctrls;

ctrls(MY_TABLE_Field1, editString1 )
     (MY_TABLE_Field2, editString2)
     (MY_TABLE_Field2, editString3);


void updateDbOnEditString()
{
   Sql sql;
   sql * ctrls.Update(MY_TABLE).Where(MY_TABLE_ID == index);
}

void Query()
{
   ctrls.Load( MY_TABLE, MY_TABLE_ID == index);
}



This is quite handy to use

Another way is to use an SqlArray object and set EditStrings as the controls for the each string field

Re: sql + editstring [message #33082 is a reply to message #32350] Wed, 06 July 2011 10:06 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1194
Registered: March 2006
Location: Italy
Senior Contributor
Didier wrote on Tue, 10 May 2011 20:16

Hi begnur,

you can use an 'SqlCtrls' object to achieve what you want.

You can do something like this:

SqlCtrls ctrls;

ctrls(MY_TABLE_Field1, editString1 )
     (MY_TABLE_Field2, editString2)
     (MY_TABLE_Field2, editString3);


void updateDbOnEditString()
{
   Sql sql;
   sql * ctrls.Update(MY_TABLE).Where(MY_TABLE_ID == index);
}

void Query()
{
   ctrls.Load( MY_TABLE, MY_TABLE_ID == index);
}



This is quite handy to use

Another way is to use an SqlArray object and set EditStrings as the controls for the each string field




Hello,

this example is very nice. SqlCtrls seems to have many potentiality but it looks not documented in contrast to SqlArray.
I tried your example but with a droplist instead of editString2 and Insert procedure.
It seems that editString1 pass its value to the table but the droplist miss its task.
May I ask a similar test case with a droplist (containing pairs of key, value).

Thanks,
Luigi
Re: sql + editstring [message #33083 is a reply to message #32347] Wed, 06 July 2011 10:33 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

spotted an error in the code!



begnur wrote on Tue, 10 May 2011 17:48

how to pass WString from EditString to Sql and from Sql To EditString

for example (below exmaples are only for demonstration I need how to do this. and again characters are non ascii

EditString editstr
 String s = editstr->GetString()
// s contains "" , database contains p,q,r where p,q,r as string
Sql sql
sql * Select(p).From(databse).Where(q = s)

// clearing s string
s.Clear();
while(sql.Fetch())
   s.Append(sql[p]);

editstr->SetString(s);






In line
sql * Select(p).From(databse).Where(q = s)


Must be
sql * Select(p).From(databse).Where(q == s)


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: sql + editstring [message #33926 is a reply to message #32347] Mon, 26 September 2011 21:33 Go to previous messageGo to next message
begnur is currently offline  begnur
Messages: 6
Registered: May 2011
Location: Turkmenistan
Promising Member
thank you all
Re: sql + editstring [message #34691 is a reply to message #33082] Tue, 06 December 2011 15:10 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

forlano wrote on Wed, 06 July 2011 10:06

this example is very nice. SqlCtrls seems to have many potentiality but it looks not documented in contrast to SqlArray.
I tried your example but with a droplist instead of editString2 and Insert procedure.
It seems that editString1 pass its value to the table but the droplist miss its task.
May I ask a similar test case with a droplist (containing pairs of key, value).

No answer to this question... Why ? Isn't it possible to use DropList with SqlCtrls ?

Thanks to confirm that it's impossible, or to tell how to do that : I cannot have it working too, and don't understand why ?

I can have it working for most Edit controls (EditString, EditInt, EditDouble, EditDate, DocEdit...) but not with DropList Sad
Re: sql + editstring [message #34698 is a reply to message #34691] Tue, 06 December 2011 19:18 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi alls,

I agree with Jibe. I use SqlCtrls as powerful tools to handle data from MySql or PostGreSql databases. EditString etc.. work well but it is impossible or I don't not know how to do the same with droplist Sad .

Have an idea how to deal with that issue?

Thanks in advance Razz

Regards

Biobytes
Re: sql + editstring [message #34722 is a reply to message #32347] Thu, 08 December 2011 16:21 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

With DropList, the key is well stored in the database. But this stored key doesn't change the DropList when it is repainted. I cannot understand why...

Some help would be appreciated ! Is it normal (I don't think so...) or is it a bug ?
Re: sql + editstring [message #34723 is a reply to message #34722] Thu, 08 December 2011 18:31 Go to previous messageGo to next message
forlano is currently offline  forlano
Messages: 1194
Registered: March 2006
Location: Italy
Senior Contributor
jibe wrote on Thu, 08 December 2011 16:21

Hi,

With DropList, the key is well stored in the database. But this stored key doesn't change the DropList when it is repainted. I cannot understand why...



Perhaps it is matter of Convert function that should be associated with this ctrl. Please see this whole thread that contains a test case
http://www.ultimatepp.org/forum/index.php?t=msg&th=6105& amp;start=0&S=1e77c4fca329192008798c8672418d7a

Luigi
Re: sql + editstring [message #34742 is a reply to message #34723] Fri, 09 December 2011 13:46 Go to previous messageGo to next message
begnur is currently offline  begnur
Messages: 6
Registered: May 2011
Location: Turkmenistan
Promising Member
again thank you
Re: sql + editstring [message #34750 is a reply to message #34742] Fri, 09 December 2011 21:17 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi Luigi,

Thank you for your support and helpful information. I will try it asap.

Regards

Biobytes
Re: sql + editstring [message #34752 is a reply to message #34723] Fri, 09 December 2011 23:42 Go to previous message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

forlano wrote on Thu, 08 December 2011 18:31

Perhaps it is matter of Convert function that should be associated with this ctrl.

Thanks for your suggestion ! In fact, it's no need to use the convert function in my case, as the droplist is not in an SqlArray.

In fact, the problem was the initialization of the DropList : Adding the strings of the list must be done before setting the value ! I did not pay attention that it was done after in my case ! Embarassed
Previous Topic: Sqlite Delete not working [SOLVED]
Next Topic: More .sch files?
Goto Forum:
  


Current Time: Fri Jun 21 22:16:44 CEST 2024

Total time taken to generate the page: 0.01762 seconds