Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server stored procedure for newid()
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00275123
Message ID:
00275163
Views:
23
>I am trying to create my first client/server application using MS SQL server as the backend. I ran my VFP tables through the upsizing wizard and can now read and write to the tables using remote views. When I attempt to add a NEW record, I get an error.
>
>The code in kbizobj.onnew() is looking for a stored procedure called "sp_NewIDmytable" where mytable is the name of the table for the bizobj I am working on. I have not built any stored procedures in the SQL database for my tables and could not find any documentation on the subject.
>
>Does anyone have an example of what the stored procedure should be? When running against client/server data is the id.dbf table no longer used? How is the unique id generated?
>
>Kind Regards,
>
>Mat

Matt,

There are a couple of things you can do.

1. Write the stored procedure(s). I thought it actually called sp_NewID myTable Passing myTable? Or does it actually call sp_NewIDMyTable ???
Basically the stored procedure will do the same thing NewID() does... it shouldn't be to hard to translate it to T-SQL. Basically accept the Table Name, start a trasaction, select the last value... update the lastvalue + 1, end the transaction, return the ID.

2. Change your ID fields to SQL Server Identity fields... then they will automatically create values and auto-increment for you.

3. Move the NewID() calls in your DBC from the Tables to the Views... Modify the NewID program to use a remote view of the id.dbf table. This may be the best way, espessially if you have written your program to populate FK in child tables with the parent PK prior to saving the parent.

BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform