Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Nov 16, 2018 5:28 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 2:06 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
curseur wrote:
The problem is into the db.sqlexecute line.

I don't know if there is something to add. I believe not.


db.SQLExecute("INSERT INTO client (adressecivil,pays,codepostale,ville) VALUES "+"('"+adresse.text+"','"+nom.text+"','"+courriel.text+"','"+prenom.text+"'"+" WHERE motpasse="+App.pass+")" )
db.Commit


taking RS out of the picture for a second, your insert statement is not valid.

should be:

db.SQLExecute("INSERT INTO client (adressecivil,pays,codepostale,ville) VALUES ('" + adresse.text + "','"+nom.text + "','" + courriel.text + "','" + prenom.text +"')")


to help avoid this type of headache, it is a lot easier to go with database insert record.


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 2:18 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
Read TimHare's post about NOT including a WHERE clause in an insert statement.

You are inserting a new record there is no need to qualify it with a WHERE clause.

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 4:59 pm 
Offline

Joined: Sat Jan 26, 2013 7:02 pm
Posts: 14
Quote:
db.SQLExecute("INSERT INTO client (adressecivil,pays,codepostale,ville) VALUES ('" + adresse.text + "','"+nom.text + "','" + courriel.text + "','" + prenom.text +"')")


With this code, how to choose a dedicated user?
This is the reason that I absolutely must use the WHERE clause.

Merci de votre collaboration.

Alain

_________________
MacMiniServer 10.8.2


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 5:06 pm 
Offline

Joined: Sat Jan 26, 2013 7:02 pm
Posts: 14
But if I would rather use UPDATE it may be better!

Sorry!

_________________
MacMiniServer 10.8.2


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 6:18 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
Now you lost me...

Is this a new record you are attempting to insert or are you attempting to update an existing record?

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 6:32 pm 
Offline

Joined: Sat Jan 26, 2013 7:02 pm
Posts: 14
UPDATE

db.sqlexecute ("UPDATE client SET adressecivil= ' " +adresse.text+" ' , ville = ' "+prenom.text+ " ' , pays = ' "+nom.text+ " ' , codepostale = ' "+courriel.text+" ' WHERE motpasse = ' "+App.pass.text+ " ' " )

I'm not really far, but it is not exactly right.


:roll:

_________________
MacMiniServer 10.8.2


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 7:57 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
curseur wrote:
UPDATE

db.sqlexecute ("UPDATE client SET adressecivil= ' " +adresse.text+" ' , ville = ' "+prenom.text+ " ' , pays = ' "+nom.text+ " ' , codepostale = ' "+courriel.text+" ' WHERE motpasse = ' "+App.pass.text+ " ' " )

I'm not really far, but it is not exactly right.


:roll:


Then why on this earth were you attempting to insert in the first place? :wink:

Try something like this:

dim s as string
s = "UPDATE client SET adressecivil= '" + adresse.text + "' "
s = s + ", ville = '" + prenom.text + "' "
s = s + ", pays = '" + nom.text + "' "
s = s + ", codepostale = '" + courriel.text + "' "
s = s + " WHERE motpasse = '" + App.pass.text + "' ;"

db.sqlexecute(s)


Not tested on this end since I'm not setting up a database since I can't type more than a couple of lines at a time right now.

Also, is "pays" a numeric field? if so you need to use one of the conversion functions like val(), cdbl(), same goes for any other numeric field which you would then not need to enclose in single quotes.

_________________
Future RS guru.
Ride the world!


Last edited by HMARROQUINC on Sun Jan 27, 2013 9:26 pm, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 7:59 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Don't put a space between the single quote and the data.

db.sqlexecute ("UPDATE client SET adressecivil= '" +adresse.text+"' , ville = '"+prenom.text+ "' , pays = '"+nom.text+ "' , codepostale = '"+courriel.text+"' WHERE motpasse = '"+App.pass.text+ "' " )

TIP: create your sql in a string variable so you can look at in the debugger.

TIP: copy the string into a query browser so you can manipulate the sql and get it just right. Then adjust your code until it produces the same sql string.


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Sun Jan 27, 2013 10:30 pm 
Offline

Joined: Sat Jan 26, 2013 7:02 pm
Posts: 14
Please forgive me for these errors. Is that I have not used RealBasic for over 3 years.

The error is in the instance App.pass.text. It must be App.pass. You understand why.

db.sqlexecute ("UPDATE client SET adressecivil='"+adresse.text+"', ville='"+prenom.text+"', pays='"+nom.text+"' , codepostale='"+courriel.text+"' WHERE motpasse='"+App.pass+"'" )


Both codes run perfectly.

s = "UPDATE client SET adressecivil='"+ adresse.text + "'"
s = s + ", ville ='" + prenom.text + "'"
s = s + ", pays ='" + nom.text + "'"
s = s + ", codepostale ='"+ courriel.text+ "'"
s = s + " WHERE motpasse ='"+ App.pass + "'"
db.sqlexecute(s)


Very happy to reconnect with RealBasic and especially WEB version.
Thank you to those who kindly help me.

Alain

_________________
MacMiniServer 10.8.2


Top
 Profile  
Reply with quote  
 Post subject: Re: db.sqlexecute
PostPosted: Mon Jan 28, 2013 12:51 am 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
Take a look at the databaserecord class. It makes it easier to debug problems like this one. It might require a bit more typing but personally I believe it makes things easier to follow. Yes, I like verbose code :wink:

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


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

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