>>Hello:
>>
>>I am trying to use SPT with an app and getting an error. In this test app. I have a form with a pageframe in it. The two pages of the page frame is for search and detail edit respectively. The relevant codes in the form are given below:
>>
>>*Form Init
>>
>>WITH THISFORM
>> .nConnHandle = SQLCONNECT('Relate')
>> IF !(.nConnHandle > 0)
>> = MESSAGEBOX('SQL Connect failure.')
>> RETURN .F.
>> ENDIF
>>
>> IF SQLEXEC(.nConnHandle, 'SELECT * FROM relative WHERE relid = 0', 'a_relate') = -1
>> = MESSAGEBOX('SQL failure.')
>> RETURN .F.
>> ENDIF
>>ENDWITH
>>
>>**************
>>
>>*-- On the search button click
>>WITH THISFORM
>> IF SQLEXEC(.nConnHandle, 'SELECT * FROM relative WHERE ' + lcWhereCondition, 'a_relate') = -1
>> = MESSAGEBOX('SQL failure.')
>> ELSE
>> IF RECCOUNT() = 0
>> = MESSAGEBOX('No matching record found.')
>> ELSE
>> = CURSORSETPROP('Tables', 'relative', 'a_relate')
>> = CURSORSETPROP('UpdatableFieldList', cUpdatableFieldList, 'a_relate')
>> = CURSORSETPROP('KeyFieldList', 'relid', 'a_relate')
>> = CURSORSETPROP('WhereType', 3, 'a_relate')
>> = CURSORSETPROP('UpdateType', 1, 'a_relate')
>> = CURSORSETPROP('SendUpdates', .T., 'a_relate')
>> = CURSORSETPROP('Buffering', 5, 'a_relate)
>> .Refresh()
>> ENDIF
>> ENDIF
>>ENDWITH
>>
>>*****************
>>When I make any edit of the data in the detail screen and try to save it, I get the following tableupdate error:
>>
>>'No update tables are specified. Use Tables property of the cursor.'
>>
>>This I find through AERROR function. Now what is strange is: I've set the Tables property using the CURSORSETPROP as you can see. Could anyone help me find where I am going wrong?
>>
>>Thanks in advance for your help.
>>
>>Rahul Chatterjee
>
>Hello Rahul,
>
> Don't leave your CURSORSETPROP('Tables', 'relative', 'a_relate') hanging. I mean put them within IF ENDIF. this way you can determine sucess/failure of it.
>In case of failure, see what error you'r getting.
>
>
>IF NOT CURSORSETPROP('Tables', 'relative', 'a_relate')
> WAIT WIND 'Can not set "Tables" property'
>ENDIF
>
>Bye
>Jayesh
Hello Jayesh:
Thanks for your reply. I forgot to mention that after I got the error, I have done some testing with the CURSORSETPROP('Tables', 'relative', 'a_relate') statement. They are as follows:
First, I had something like
llReturn = CURSORSETPROP('Tables', 'relative', 'a_relate')
WAIT WINDOW IIF(llReturn, "Success", "Failure")
Finally, I added a few lines after my TABLEUPDATE() statement something like:
IF !TABLEUPDATE(0, .F., "a_relate")
= AERROR(aTest)
= MESSAGEBOX(aTest(2))
ENDIF
The messagebox mentioned above was telling me:
'No update tables are specified. Use Tables property of the cursor.' Although the cursorsetprop was returning .T.
However, I read some documentation in the meantime and I think I've found the answer to this problem. The Microsoft Docs say that the cursor created with SPT technique can not be associated with controls in a form and the such cursors are readonly (quite naturally, if you think about the fact that it is generated by an SQL statement). Only way you can update the backend database through the use of this kind of cursors is though the UPDATE SQL statement where you'll have to use: SET = some value etc.
Thanks anyway.
Rahul Chatterjee
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only