Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Sep 22, 2019 10:26 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: SQLite Question
PostPosted: Mon Jan 28, 2013 4:13 pm 
Offline

Joined: Tue Jan 08, 2013 8:27 pm
Posts: 38
I have a page where i can view 'tenants' (database records) in a listbox1 on a page called 'Tenants'

see screenshot
Image

when i press the edit button i want it to display a different page and show the results in different textfeilds (see second screenshot)

Image

does anyone know how i would go about this please

thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Mon Jan 28, 2013 4:39 pm 
Offline
Real Software Engineer

Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7858
Location: Canada, Alberta, Near Red Deer
this has nothing to do with sqlite

it has everything to do with how you manage data internally in your application

when you get the data that fills the table view what do you put in each rowtag ?
anything ?

if not then I would put the primary key for that row (at the very least) so when a row is clicked & edited you can grab all the dat & put it in the various fields (as you showed)

ideally each row in the initial table view has a "rowtag" that is an instance of a class called Tenant that holds all the dat so you can just hand that to the other multi field view

_________________
Norman Palardy (Real Software)


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Mon Jan 28, 2013 4:45 pm 
Offline

Joined: Wed May 20, 2009 4:43 pm
Posts: 958
What I usually do is store the primary key in the rowTag property of your listbox, and add a constructor to the 'Tenant' window with the optional key (get the value from the rowtag, and pass that to the window's constructor).

Sub Constructor(optional tenantKey as integer = -1)
// Calling the overridden superclass constructor.
Super.Constructor

' Store the tenant key in a property of the window
Self.mTenantKey = tenantKey

If tenantKey > 0 Then
' Existing tenant - Get tenant information from database

Else
' New tenant - set up any default values here

End If
End Sub


Make sure you update the existing record (instead of inserting a new one) if the key > 0

_________________
RB 2009r4 Windows XP


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Mon Jan 28, 2013 5:01 pm 
Offline

Joined: Tue Jan 08, 2013 8:27 pm
Posts: 38
sorry i don't quite get the drift of it.


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Mon Jan 28, 2013 7:35 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
I really enjoy helping people out but you need to do your homework and ask specific questions. From what I can see in your screen captures you are using a datacontrol, is this right? Is this your project? How are you displaying data in the listbox in the first form?

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Tue Jan 29, 2013 12:43 pm 
Offline

Joined: Tue Jan 08, 2013 8:27 pm
Posts: 38
yes i am using data control, yes it is my project i am displaying the listbox by this code

dim sql as string
sql = "SELECT * FROM Tenants"

deleteallrows

dim data as RecordSet
data = komplete.SQLSelect(sql)

if data <> Nil then
while not data.EOF
listbox1.AddRow(data.field("TenantID").StringValue, data.field("currentaddress").StringValue, data.field("title").StringValue, _
data.field("firstname").StringValue, data.field("surname").StringValue)
data.MoveNext
wend
data.Close
end if


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Tue Jan 29, 2013 3:14 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
Is TenantId the unique key row in your table?

Is there a chance you can drop the datacontrol? It is much better to handle your database using code.

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Tue Jan 29, 2013 3:37 pm 
Offline

Joined: Tue Jan 08, 2013 8:27 pm
Posts: 38
Yeh I can drop data control only used it as it was the only way I knew how to display info, and yes tenantid is the unique key

Thanks for your patience btw, I am kinda new to this


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Tue Jan 29, 2013 4:46 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
I'll help you out but please first read this thread:

viewtopic.php?f=3&t=4342

_________________
Future RS guru.
Ride the world!


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Wed Jan 30, 2013 3:37 am 
Offline

Joined: Tue Jan 08, 2013 8:27 pm
Posts: 38
Thanks :D


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Sat Feb 02, 2013 12:08 pm 
Offline

Joined: Tue Jan 08, 2013 8:27 pm
Posts: 38
its fine ive sorted it

thanks


Top
 Profile  
Reply with quote  
 Post subject: Re: SQLite Question
PostPosted: Sat Feb 02, 2013 1:28 pm 
Offline
User avatar

Joined: Sun Jan 25, 2009 5:11 pm
Posts: 576
Location: Guatemala, Central America
good deal!

_________________
Future RS guru.
Ride the world!


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

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