Is it better to use linq2sql to generate classes for stored procedures, or to call the stored procedures directly?
Tag : chash , By : Laques
Date : March 29 2020, 07:55 AM
around this issue Mapping to LINQ2SQL has a serious advantage in being type-safe - you don't really have to worry about parsing the results or adding command parameters. It does it all for you. On the other hand with calling stored procedures directly with SQLcommand and DataReader proves to have better performance (especially when reading/changing a lot of data).
|
Call stored procedures from another stored procedure or only one SP for better efficiency?
Date : March 29 2020, 07:55 AM
To fix this issue Assuming that you are updating 9 tables in one action like(button click),maintaining transaction may be your requirement ,so i would like to suggest you to make one storedprocedures and maintain transaction in it,rather than 9 different procedures..
|
How to call Stored Procedures (with 2 parameters) in a Stored Procedure?
Date : March 29 2020, 07:55 AM
hope this fix your issue I see two issues here: Your procedure apparently takes two parameters, @myDate and @ServerName, which you have not declared yet. Do so by adding the names and the types between the procedure name and AS. CREATE PROCEDURE [dbo].[SP_All]
@myDate datetime,
@ServerName sysname
AS
BEGIN
exec sp_1 @myDate, @ServerName
exec sp_2 @myDate, @ServerName
exec sp_3 @myDate, @ServerName
exec sp_4 @myDate, @ServerName
END
|
VB.NET: How to call another stored procedures based on stored procedure result and display all results?
Date : March 29 2020, 07:55 AM
this will help This would be an ideal candidate for using the Repeater Class. You can nest them to handle your logic of displaying data based on an initial DataSource. Since I do not know your Model definition, I have used generic placeholders that you will need to replace in the example code. Examples of these placeholders include "SomeFieldFromSp2DataTable", "FieldNameOfId", "TheClassOfItemsInYourArrayList", etc. First, make the markup in the ASPX page. The HeaderTemplate contains markup to use for the header of a DataSource. The ItemTemplate is the markup for the body of each item in your DataSource. FooterTemplate does markup at the end of a DataSource. In this instance I mocked it up so it would create nested HTML Tables. <asp:Repeater ID="rptSP1" runat="server">
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="lblSP1" runat="server"><%# CType(Container.DataItem, TheClassOfItemsInYourArrayList).FieldNameOfId%></asp:Label></td>
</tr>
<asp:Repeater ID="rptSP2" runat="server">
<HeaderTemplate>
<tr><td><table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="lblSP2" runat="server"><%#DataBinder.Eval(Container.DataItem, "SomeFieldFromSp2DataTable")%></asp:Label></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></td></tr>
</FooterTemplate>
</asp:Repeater>
<asp:Repeater ID="rptSP3" runat="server">
<HeaderTemplate>
<tr><td><table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="lblSP3" runat="server"><%#DataBinder.Eval(Container.DataItem, "SomeFieldFromSp3DataTable")%></asp:Label></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table></td></tr>
</FooterTemplate>
</asp:Repeater>
</ItemTemplate>
</FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
rptSP1.DataSource = YourArrayList
rptSP1.DataBind()
Private Sub rptSP1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptSP1.ItemDataBound
'Perform this check because you only need the actual data items.
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
Dim intIdFromSp1 As Integer = CType(e.Item.DataItem, TheClassOfItemsInYourArrayList).IdField
Dim rptSP2 As Repeater = CType(e.Item.FindControl("rptSP2"), Repeater)
Dim rptSP3 As Repeater = CType(e.Item.FindControl("rptSP3"), Repeater)
'Code that gets the data from the other SPs would be in a Function called GetDataTableFromSP2.
rptSP2.DataSource = GetDataTableFromSP2(intIdFromSp1)
rptSP2.DataBind()
rptSP3.DataSource = GetDataTableFromSP3(intIdFromSp1)
rptSP3.DataBind()
End If
End Sub
|
Is it correct to use SET NOCOUNT ON only in the root stored procedure in case you want to call other stored procedures i
Date : March 29 2020, 07:55 AM
Hope this helps SET NOCOUNT ON will prevent row count messages from being sent by the stored procedure, or by any nested stored procedures (or dynamic batches). If a nested procedure or batch sets NOCOUNT OFF, row count messages will be sent for the statements in that batch, but the NOCOUNT OFF behavior will be restored when control returns to the outer proc/batch.
|