I am using the UltraWebGrid and want to track who is making a change to the data. I am using stored procedures for my select, insert, update and delete commands in the grid. When someone updates a record, I would like to send the username (current user logged in) to the stored procedure so that it can be updated in the table, but I can't figure out how to send the username as a parameter. Any help is appreciated. Thanks!
Will do...thanks for your help! I truly appreciate it.
I can read the post, yes. In the future, you can wrap that code in a <code> block to prevent Visual Studio's code from being oddly formatted in these forums.
If you need further assistance, then it will take further in-depth investigation. Because the issue relates to Microsoft's SqlDataSource control, and is not itself unique to Infragistics controls, I recommend that you post to MSDN's forums.
WOW...not real sure about what happened with that last message...Can you read that or should I repost?
This is exactly what I was hoping I would be able to use. I actually tried this before posting, but could never get it to work correctly. This is what my code looks like: As you can see, I tried to add the username defaultvalue, and it works...kind of...it actually inserts "<% HttpContext.Current.User.Identity.Name %>" into the table. I'm just not sure of the proper syntax I should be using at this point.
<asp:SqlDataSource ID="SqlDataSource" runat="server"ConnectionString="<%$ ConnectionStrings:MTMPConnectionString %>"DeleteCommand="usp_del_tblLookup_Diag_Codes_CHF"InsertCommand="usp_ins_tblLookup_Diag_Codes_CHF"SelectCommand="usp_get_tblLookup_Diag_Codes_CHF"UpdateCommand="usp_upd_tblLookup_Diag_Codes_CHF"OnInserted="SqlDataSource_Inserted"DeleteCommandType="StoredProcedure"InsertCommandType="StoredProcedure"SelectCommandType="StoredProcedure"UpdateCommandType="StoredProcedure"><DeleteParameters><asp:Parameter Name="Lookup_ID" Type="Int32" /></DeleteParameters><UpdateParameters><asp:Parameter Name="Lookup_ID" Type="Int32" /><asp:Parameter Name="Diag_Code" Type="String" /></UpdateParameters><InsertParameters><asp:Parameter Name="Diag_Code" Type="String" /><asp:Parameter Name="User_Name" Type="String" DefaultValue="<% HttpContext.Current.User.Identity.Name %>" /></InsertParameters></asp:SqlDataSource>
I found another page through MSDN that may help:Using Parameterized Queries with the SqlDataSource
In particular, take a look at "Step 5: Assigning Parameter Values Programmatically".