Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Oct 18, 2018 4:53 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 1:25 pm 
Offline

Joined: Fri Nov 18, 2005 7:26 pm
Posts: 63
DaveS wrote:
are you SURE this is generating a valid SQL statement?

sql = "Select ID, Firstname, Lastname, email from people where ID = " + lstPeople.Cell(lstPeople.Listindex, 0)

are you SURE there is a record to BE editted?

Have you tried using the UPDATE SQL method?


AND DO NOT DIM THE DATABASE INSIDE A LOCAL PROCEDURE..... you do not want to connect and disconnect on every single operation.



There is data in the ListBox .. it puts a record in there from the Add. I click on that record which has an ID of 1.

I have used a MsgBox to check for (SQL) and when I do this I Get the message saying

Select ID, Firstname, Lastname, email from people where ID = 1

So I assume its pulling the right information.


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 1:47 pm 
Offline

Joined: Fri Nov 18, 2005 7:26 pm
Posts: 63
I am frustrated now.. I give up!!!


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 2:08 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Ok.... me too..... can't help you if you are not willing to try to understand, to try things that are suggested to you....

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 2:22 pm 
Offline

Joined: Fri Nov 18, 2005 7:26 pm
Posts: 63
DaveS wrote:
Ok.... me too..... can't help you if you are not willing to try to understand, to try things that are suggested to you....


I really am trying to understand this. I have tried what you suggested and after fixing one of the Syntax erorrs, I ran the program but STILL does the same thing (Still have a NilObjectException).

This is what I have done in my edit

SQL= _
"UPDATE people "+_
" SET firstname='"+trim(txtfirstname.text)+"'," + _
" lastname ='"+trim(txtlastname.text)+"',"+_
" email="+trim(txtemail.text+"'"+_
" WHERE ID= "+lstPeople.Cell(lstPeople.Listindex, 0)
'
DB.SQLExecute SQL
If DB.Error Then
DB_Error(rollback,SQL)
Return False
Else
DB.Commit
Return True
End If


SO I dont think the error is in the Editing , it must be somewhere else. Just dont have enough experience to know where else this may be .

The frustrating thing is that I have this working in another program, but the only difference there is that i had created the database in that program with the built in SQL Database Creator and I am trying to edit my program so that I can create the database programatically but now the edit does not work.


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 3:41 pm 
Offline

Joined: Fri Nov 18, 2005 7:26 pm
Posts: 63
Thank you.. Ok so now this is "working" in so much as I am not getting the error message any more. Although it is NOT updating the database itself. I have seen viewed the table but there are no changes in there .. So you know I have built the application, so that it does not create the database from scratch every time and tried it in there.



For some reason I had to remove the error checking to get it not to error.

SQL= _
"UPDATE people "+_
" SET firstname='"+trim(txtfirstname.text)+"'," + _
" lastname ='"+trim(txtlastname.text)+"',"+_
" email="+trim(txtemail.text)+"'"+_
" WHERE ID= "+lstPeople.Cell(lstPeople.Listindex, 0)
'
DB.SQLExecute SQL

DB.Commit


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 4:30 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
Try this:

dim sql as string
sql = "UPDATE people "
sql = sql + "SET firstname = '" + txtfirstname.text.trim + "'"
sql = sql + ", lastname = '" + txtlastname.text.trim + "'"
sql = sql + ", email = '" + txtemail.text.trim + "'"
sql = sql + " WHERE ID = " + cstr(lstpeople.cell(lstpeople.listindex, 0)) + " ;"
MsgBox sql


Read the message displayed in the messagebox. Better yet, in the debugger check the value of sql, grab it and run it in a db manager and see if it runs without error.

Once you get this working you should read about escaping your sql statements.

* This is untested code, but I believe I got all the single and double quotes correctly.

Also, I'm assuming that ID is a numeric field.

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 5:49 pm 
Offline

Joined: Fri Nov 18, 2005 7:26 pm
Posts: 63
HMARROQUINC wrote:
Try this:

dim sql as string
sql = "UPDATE people "
sql = sql + "SET firstname = '" + txtfirstname.text.trim + "'"
sql = sql + ", lastname = '" + txtlastname.text.trim + "'"
sql = sql + ", email = '" + txtemail.text.trim + "'"
sql = sql + " WHERE ID = " + cstr(lstpeople.cell(lstpeople.listindex, 0)) + " ;"
MsgBox sql


Read the message displayed in the messagebox. Better yet, in the debugger check the value of sql, grab it and run it in a db manager and see if it runs without error.

Once you get this working you should read about escaping your sql statements.

* This is untested code, but I believe I got all the single and double quotes correctly.

Also, I'm assuming that ID is a numeric field.



The Msgbox displays the contents of the Text Boxes. So in theory this should update the database. But when I check the DB it does not edit the data. it stays as it was before


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 5:52 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
did you add the db.sqlexecute and db.commit ?

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 5:56 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
check your private messages

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sat Mar 16, 2013 6:13 pm 
Offline

Joined: Fri Nov 18, 2005 7:26 pm
Posts: 63
Yes I have them both. And I have done a step through of the code, it seems to execute those lines and the listbox is updated with the relevant information but when I then look at the database, the informatin is as it was before.

Dim sql as String

sql = "UPDATE people "
sql = sql + "SET firstname = '" + txtfirstname.text.trim + "'"
sql = sql + ", lastname = '" + txtlastname.text.trim + "'"
sql = sql + ", email = '" + txtemail.text.trim + "'"
sql = sql + " WHERE ID = " + cstr(lstpeople.cell(lstpeople.listindex, 0)) + " ;"
MsgBox sql

DB.SQLExecute (SQL)

Db.Commit



lstPeople.Cell(lstPeople.Listindex, 1) = trim(txtFirstName.text)
lstPeople.Cell(lstPeople.Listindex, 2) = trim(txtLastname.Text)
lstPeople.Cell(lstPeople.Listindex, 3) = trim(txtemail.text)


Top
 Profile  
Reply with quote  
 Post subject: Re: Database Not found
PostPosted: Sun Mar 17, 2013 2:24 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Check db.Error between db.sqlexecute and db.commit (commit clears any error information that may have been there). The fact that the listbox is being updated with the correct information is meaningless, because it isn't coming from the database - you're using the textfields.

Either you're missing an error from the update, or you're updating a different database file than you're checking (I've seen this happen many times).


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

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