iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I have an isDataSource connected to an insert proc with a GUID
The insert proc does not expect or require the GUID; however, when WebGrid attempts an insert, I get an error saying the field cannot be blank.How do I get this to work?
George, in normal GUID case, the Grid should be able to insert the row successfully without additional code. However, your case is a bit different since the GUID is assigned in the backend, and not from front/middle layer.
Fortunately, WebGrid has a solution for your scenario which is very similar to the solutions in the KB article that Gordon provided. In short, you need to pass the GUID from backend into datasource level which involves two phases:
<InsertParameters> <asp:Parameter Direction="InputOutput" Name="BusinessID" Type="Object" /> ...
DataObjectMethodAttribute(DataObjectMethodType.Insert, true)] public int DoInsert(ref System.Guid BusinessID, ...) { // your insert call to SP objecet returnValue = DAL.InvokeYourInsertSP(params); // assign the returnValue, which should be the GUID value from your SP call BusinessID = returnValue; }
The above code assumes that your SP should return the GUID value properly, as in the case of Northwind sample where it returns the identity of the OrderId.
When an InputOutput parameter (ref) is assigned back from DoInsert method, WebGrid automatically detects the new value and assign it to the datasource and UI.
Hope this helps,James.
Hi George,
Actually we have a knowledge base about retrieving identity, probably you can use it also, you can browse it in http://support.intersoftpt.com/KBArticle.aspx?aid=207 or http://support.intersoftpt.com/KBArticle.aspx?aid=227.
Hope this helps.
Best Regards,
Gordon Tumewu
Gordon,My issue is not in retrieving the GUID. It is in INSERTING the GUID. I will post a video for you.
Thanks
You can find the video Here
It's true, I noticed that your issue is in inserting, the issue that you have because that the ID column cannot be null, that's why I point to the knowledge base, if you check the knowledge base contain step by step to handle the inserting problem if the ID cannot be null. I think it's similliar with your issue.
Gordon, the insert stored proc, does not require the id. The ID is passed internally. Here it is:
[dbo].[sp_Business_Insert]( @BusinessName nvarchar(100), @Address1 nvarchar(100), @Address2 nvarchar(50), @City nvarchar(50), @State nvarchar(20), @PostalCode nvarchar(20), @Country nvarchar(30), @ProfessionalID1 nvarchar(50), @ProfessionalID2 nvarchar(50), @ProfessionalID3 nvarchar(50), @StatusID tinyint, @AdminFirstName nvarchar(20), @AdminLastName nvarchar(20), @AdminPhone nvarchar(20), @AdminPhoneExt nvarchar(10), @AdminEmail nvarchar(50), @GName nvarchar(20))ASDECLARE @BusinessID uniqueidentifierSET @BusinessID=NEWID()
SET NOCOUNT OFF;INSERT INTO [dbo].[Business] ([BusinessID], [BusinessName], [Address1], [Address2], [City], [State], [PostalCode], [Country], [ProfessionalID1], [ProfessionalID2], [ProfessionalID3], [StatusID], [AdminFirstName], [AdminLastName], [AdminPhone], [AdminPhoneExt], [AdminEmail], [GName]) VALUES (@BusinessID, @BusinessName, @Address1, @Address2, @City, @State, @PostalCode, @Country, @ProfessionalID1, @ProfessionalID2, @ProfessionalID3, @StatusID, @AdminFirstName, @AdminLastName, @AdminPhone, @AdminPhoneExt, @AdminEmail, @GName); SELECT BusinessID, BusinessName, Address1, Address2, City, State, PostalCode, Country, ProfessionalID1, ProfessionalID2, ProfessionalID3, StatusID, AdminFirstName, AdminLastName, AdminPhone, AdminPhoneExt, AdminEmail, GName FROM ArcBusiness WHERE (BusinessID = @BusinessID)
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname