Using insert stored procedures


Author
Message
Randy Smith
Randy Smith
StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)
Group: Forum Members
Posts: 18, Visits: 193
Can anyone give me a sample of saving data with a stored procedure. I am trying to return the uniqueidentifier and I'm not sure exactly how to go about this.

Thanks in advance.

Replies
Randy Smith
Randy Smith
StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)
Group: Forum Members
Posts: 18, Visits: 193
Thanks for the information Ben. That fixed my problem. Is it possible to use the uniqueidentifier field without using the stored procedure ?
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, it is possible to use a GUID as a primary key... I would recommend that you set the pk value within your SetDefaultValues event handler within the business object. Then, you can turn off the use of the stored procedures, and set the PrimaryKeyIsAutoIncremented property to False. However, if you want the server to assign the value, you'll need to set the "Default Value" of your field within the database to "(NEWID())", and leave the PrimaryKeyIsAutoIncremented = True so that the value will be retrieved.



If you want to assign the PK on the client side, the code would look like this:



VB:

Private Sub MyBO_SetDefaultValues()

'-- Set the pk value

Me.pkfield = Guid.NewGuid() '-- Creates a new, random GUID just like the NEWID() SQL method

End Sub



C#:

private void MyBO_SetDefaultValues()

{

   //-- Set the pk value

   this.pkfield = Guid.NewGuid(); //-- Creates a new, random GUID just like the NEWID() SQL method

}
Randy Smith
Randy Smith
StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)StrataFrame Beginner (18 reputation)
Group: Forum Members
Posts: 18, Visits: 193
Great!! Thanks for all your help.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search