Welcome! Log In Create A New Profile

Advanced

Ass 6, Q1

Posted by morris 
Announcements Last Post
Announcement : Programming Students at UNISA School of Computing 06/19/2019 02:01PM
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Ass 6, Q1
August 05, 2007 08:33PM
hi

For assignment 6, question 1, in the form AddReservations I am encountering a problem that hopefully someone can help me with.

In my form to add a reservation the user selects a student by number from a DBLookUpCombobox component. In the OnCloseUp event that is triggered by this, a query is executed (via the SQLDataSet) to show only the reservations already made for that specific student in a DBGrid on the form - all as per assignment requirements. The user goes on to specify the other details of the reservation (venue, unit, etc) and by clicking on the relevant button, these details are posted to the reservations table (actually to the ClientDataSet I believe) and the reservation is shown on the grid with the rest of the reservations for that student. All this is what the question asks for and works fine, the user can then select another student and everything does what it should.

My problem comes when I save the new reservation by calling the ApplyUpdates procedure. I assume this needs to be done before a new student is selected else the resulting query removes the reservation from the dataset. However, after the ApplyUpdates procedure is executed, if I try select a new student (resulting in an attempt at new query to display the relevant reservations) I get the error message 'Commands out of sync; you cannot run this command now'.

No matter what I try, and I have tried a lot now, I cannot seem to get around this. From what I can gather from looking on the net, that error message is due to calling a second query before doing something (I am not sure what) about the first/original query. Has anyone had this problem before, or have an idea how to sort it out.

I know this is an assignment question and I am not looking for a solution to the question, but rather a reason why I am getting this message in terms that I can understand (i.e relevant to the course material). Please help if you can.
Re: Ass 6, Q1
August 06, 2007 08:01PM
Hi Morris

I am not in a position to help you but could you please help me.... I am stuck just a few steps behind you

In the Command Text of the SQL DataSet ... how do you select the specific StudentNumber the user selected. I can do it by putting in a specific StudentNumber String ( 'SELECT * FROM reservation WHERE reservation.StudentID = ''7029-793-3'''; ), but as soon as i want to ad the LookupComboBox text I get all types of errors ... how do you put in a variable?

I would apreciate it if you could help

Thanks
Juan
Re: Ass 6, Q1
August 07, 2007 06:41AM
hi

I also struggled with this for a while, putting a variable into the SQL statement. In the statement, the value of the LookUpComboBox (i.e its text) still needs to be in quotes, so this needs to be done by concatenating open quote + LookUp.Text + close quote.

e.g WHERE Value = ''' + LookUpComboBox.Text + '''

Note that in the code editor the whole statement must be in quotes as well, so it seems like a ridiculous amount of '''',s but I'm sure you get the point. Just remember that the final value of your string must have the value of your variable between quotes, but you cannot just put 'LookUpComboBox.Text' as such as this will only read the name and not the value of your variable. (ending up in a error about no table named... something or other).

I hope that made sense, let me know if it does not help.
Re: Ass 6, Q1
August 07, 2007 06:42PM
Thanks ... it makes perfect sense .... i was close ... just did not have the combination of ridiculous quotes and + ...

I will try it tonight. Thanks

Did you sort your's out?
Re: Ass 6, Q1
August 07, 2007 06:58PM
hey

Glad to help. Unfortunately I am still struggling with my problem, everything else works nicely, all the reports and such are fine except for my one (rather big) problem. If you find yourself in the same boat and work it out please help.

Good luck
Sorry, only registered users may post in this forum.

Click here to login