Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Crystal Reports & Views
Message
 
 
À
09/10/2000 13:26:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Produits tierce partie
Divers
Thread ID:
00426924
Message ID:
00426942
Vues:
24
The answer to your question is not so easy to explain. (Hard question - hard answer <g> ;)
First of all, I'm alwost sure that you was not set automatic transaction handling on SQL Server. So, when you update view, it starts transaction on the SQL Server automatically, and than nothing ends it. So noone else see your updates. When you disconnect from server, all transactions committed automatically, though other users/connections now can see updates.
To fix your problem disconnecting probably is not the best way. You may try 2 ways:
1. Less reliable - use automatic transactions.
Before establishing connection, use following command:
=SQLSetProp(0, 'Transactions', 1) && automatic transactions
'0' as handle means default setting for all SQL connections in your application.
2. More reliable, but require more programming. I use it always because it gives me opportunity to organize complex transaction for data saving.
Before establishing connection, use following command:
=SQLSetProp(0, 'Transactions', 2) && manual transactions
Than, after updates finished, use following command to commit transaction on SQL Server:
SQLEXEC(MuHandle, "IF @@TRANCOUNT > 0 COMMIT TRANSACTION")

Little note:
I usually have global object that contains all information about connection to SQL Server, include handle, DSN, user/password etc. I added methods to that object to execute query in asynch mode, but modally (so user can cancel long query running), just execute query, manage transactions etc. Commit transaction looks like following:
procedure CommitTransaction
&& will return .F. when transaction failed, this.cError contains message (reason) why transaction cannot be committed.
RETURN THIS.Execute("IF @@TRANCOUNT > 0 COMMIT TRANSACTION")
endproc

You may look also to Rick's wwSQL class as a sample of such kind of objects.

Why I send this note? Just because you might want to commit transaction by a single command in your applications after you used 'tableupdate', instead of writing allot of code for error handling on each place.

HTH.

>I had this one pop up this weekend. I was able to fix it but don't understand why! Maybe someone can explain this one to me. This is hard to explain so keep this in mind...
>
>I have a DBC containing all of my tables and a few views (use for reports only). I also have separate DBC containing local views to the tables. The view DBC is used for data entry in the application.
>
>I am designing this application so that it can be used either with data in DBFs or SQL Server. I do a lot of SQL Passthrough for lookups etc. Because of this I have a DSN ODBC configuration pointing to the Data DBC. I create a connection using this DSN at the beginning of the application and store it in an Applicaiton property to be used whenever I need it.
>
>I have a report (Crystal Reports 8) that uses two of the views defined in the Data DBC. This is a Parent-Child relation ship (view1=Parent view2=Child). The report is connecting to the data using the same DSN described in the above paragraph.
>
>The problem is when I update data in the tables using the application, then print the report, the report does not show the updated data in one of the tables (view1). It does show updates to the other view! The only way I could get it to show the updates in view1 was to exit the applicaiton and re-start.
>
>I spent several hours trying to figure this out. Finally, I decided to try to close my connection to the DBC using sqldisconnect() prior to printing the report then recreate the connection afterwards. This fixed the problem!
>
>WHY?
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform