Sql存储过程 [英] Sql stored procedure

查看:63
本文介绍了Sql存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个名为ERP Systems的项目中工作。



我有一个关于SQL存储过程的问题。



目前我设计了一个用于输入产品详细信息的主页...即使用ajax选项卡容器我在一个选项卡中设计了产品ID,产品名称和产品名称,购买率,另一个选项卡中的销售价格。



我为页面创建了一个表,我创建了两个存储过程,用于在表中单独插入值,即在第一个选项卡中产品ID和产品名称用于在该表中插入并在第二个选项卡中使用产品名称(动态添加)我应该插入购买率,销售价格等...



是否可以这样做。



我们可以在一个表中的两个不同时间插入两个不同的值。



我使用的是sql server 2005 ,.net 2.0。





我在sql&中只有一个名为tblmasters的表。插入产品后,必须输入购买率,销售价格等。在两个不同的时间,使用两个插入查询(存储过程)..我使用ajax选项卡容器,以便选项卡面板有两种设计形式....



我不知道是否可能......我只是问你的朋友。



我的尝试:



I am working in a project called ERP Systems.

I had a question about a SQL stored procedure.

Currently I designed a masters page for entering the product details... i.e. using ajax tab container I designed product id, product name in one tab and product name, purchase rate, selling price in another tab.

I created a table for the page and I create two stored procedures for inserting the values separately in the table i.e. in first tab product id and product name is used to insert in that table and in second tab using product name (dynamically added) I should insert purchase rate, selling price etc...

is it possible for do like this.

We can insert the two different values in two different times in one table.

I am using sql server 2005, .net 2.0.


I had only one table named tblmasters in sql & after inserting products, have to enter purchase rate, selling price,etc.. at two different times, using two insert query (stored procedures).. I am using ajax tab container so that the tab panel has two design forms....

I don't know whether it is possible... i am just asking you friends.

What I have tried:

<ajax:tabcontainer style="Z-INDEX:1" id="TC" runat="server" activetabindex="0" width="346px">
<br mode="hold" xmlns:ajax="#unknown" /><ajax:tabpanel runat="server" id="tp1">
<br mode="hold" xmlns:ajax="#unknown" />
<HeaderTemplate>ADD PRODUCTS</HeaderTemplate>
<ContentTemplate>
<table style="BORDER-RIGHT: darkgray solid; BORDER-TOP: darkgray solid; BORDER-LEFT: darkgray solid" class="Border" cellSpacing=4 cellPadding=4>
    <tr class="Heading" align="center" height="10%">
        <td colspan="3">PRODUCTS</td></tr>
    <tr>
        <td>
        <asp:Label id="lblpid" runat="server" CssClass="Labels" Text="Product ID"></asp:Label>
        </td>
        <td>:</td>
        <td><asp:TextBox id="txtpid" runat="server"></asp:TextBox> </td></tr>
    <tr>
        <td>
        <asp:Label id="lblproductname" runat="server" CssClass="Labels" Text="Product Name"></asp:Label>
        </td>
        <td>:</td>
        <td>
            <asp:TextBox id="txtpname" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td colspan="3" align="center"><asp:Label ID="lblmsg" runat="server" Font-Bold="True"></asp:Label></td>
        <td align="right">
            <asp:Button ID="addprobtn" runat="server" Text="Add" OnClick="addprobtn_Click" />
        </td>
    </tr>
    <tr align="center">
        <td colspan="3">
        <asp:Panel ID="pan1" runat="server">
            <asp:GridView ID="addpro_Grid2" runat="server" Width="276px" AutoGenerateColumns="False" AllowPaging="True" OnPageIndexChanging="addpro_Grid2_PageIndexChanging" PageSize="5">
                <SelectedRowStyle CssClass="GridSelectedItem" /><AlternatingRowStyle CssClass="GridAlter" />
                <EditRowStyle CssClass="GridEditItem" />
             <Columns>
                <asp:BoundField DataField="pid" HeaderText="Products ID" />
                <asp:BoundField DataField="pname" HeaderText="Products Name" />
             </Columns>
            </asp:GridView>
        </asp:Panel> </td></tr>
        <tr> <td colspan="3">
   <center>
        <asp:ImageButton id="apbtnadd" runat="server" ImageUrl="~/admin/Images/addbtnrose.png" Height="50px" OnClick="apbtnadd_Click1" Width="60px"></asp:ImageButton>
        <asp:ImageButton id="apbtnsave" runat="server" ImageUrl="~/admin/Images/savebtnrose.png" Height="50px" Width="60px" OnClick="apbtnsave_Click"></asp:ImageButton>
        <asp:ImageButton id="apbtnedit" runat="server" ImageUrl="~/admin/Images/editbtnrose.png" Height="50px" Width="60px"></asp:ImageButton>
        <asp:ImageButton id="apbtndelete" runat="server" ImageUrl="~/admin/Images/deletebtnrose.png" Height="50px" Width="60px"></asp:ImageButton>
   </center></td></tr>
   </table>
</ContentTemplate>
</Ajax:TabPanel>
<Ajax:TabPanel runat="server" ID="tp2">
    <HeaderTemplate>PRODUCTS RATE</HeaderTemplate>
    <ContentTemplate>
    <div align="center">
        <table style="BORDER-RIGHT: darkgray solid; BORDER-TOP: darkgray solid; BORDER-LEFT: darkgray solid" cellspacing="2" cellpadding="2" width=550>
          <tr>
            <td class="Heading" align=center>PRODUCTS RATE</td>
          </tr>
        </table>
        <table style="BORDER-RIGHT: darkgray solid; BORDER-LEFT: darkgray solid" class="Border" width="550" align="center" >
        <tr>
            <td>
            <asp:Label ID="lblprpid" runat="server" CssClass="Labels" Text="Product ID"></asp:Label>
            </td>
            <td>
            <asp:TextBox id="txtprpid" runat="server"></asp:TextBox>
            </td>
            <td align="left">
            <asp:Label id="lbldate" runat="server" CssClass="Labels" Text="Date"></asp:Label>
            </td>
            <td>
            <asp:TextBox id="txtdate" runat="server"></asp:TextBox>
            <Ajax:CalendarExtender id="cedate" runat="server" Enabled="True" TargetControlID="txtdate"></Ajax:CalendarExtender>
            </td>
       </tr>
       <tr>
            <td align="left">
            <asp:Label id="lblpname" runat="server" CssClass="Labels" Text="Product Name"></asp:Label>
            </td>
            <td>
                <asp:DropDownList id="ddlname" runat="server" Width="155px">
                    <asp:ListItem>--Select--</asp:ListItem>
                </asp:DropDownList>
            </td>
            <td align="left">
                <asp:Label id="lblrate" runat="server" CssClass="Labels" Text="Purchase Rate"></asp:Label>
            </td>
            <td>
                <asp:TextBox id="txtrate" runat="server"></asp:TextBox>
            </td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Label id="lblqty" runat="server" CssClass="Labels" Text="Quantity"></asp:Label>
                </td>
                <td>
                    <asp:TextBox id="txtqty" runat="server"></asp:TextBox>
                </td>
                <td align="left">
                    <asp:Label id="lbltamt" runat="server" CssClass="Labels" Text="Total Amount"></asp:Label>
                </td>
                <td>
                    <asp:TextBox id="txttamt" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td align="left">
                    <asp:Label id="lblspamt" runat="server" CssClass="Labels" Text="Selling Price/Unit"></asp:Label>
                </td>
                <td>
                    <asp:TextBox id="txtspamt" runat="server"></asp:TextBox>
                </td>
                <td align="left">
                    <asp:Label id="lblstock" runat="server" CssClass="Labels" Text="Stock In Hand"></asp:Label>
                </td>
                <td>
                    <asp:TextBox id="txtstock" runat="server" ReadOnly="True"></asp:TextBox>
                </td>
             </tr>
             <tr align="right">
                <td colspan="4">
                    <asp:Button ID="praddbtn" runat="server" Text="Add" OnClick="praddbtn_Click1" />
                </td>
             </tr>
         </table>
         </div>
         <table style="BORDER-RIGHT: darkgray solid; BORDER-LEFT: darkgray solid; BORDER-BOTTOM: darkgray solid" class="Border" width="550" align="center">
            <tr align="center">
                <td colspan="4">
                    <asp:GridView ID="pr_Grid" runat="server" AutoGenerateColumns="False">
                        <SelectedRowStyle CssClass="GridSelectedItem" /><AlternatingRowStyle CssClass="GridAlter" />
                        <EditRowStyle CssClass="GridEditItem" />
                     <Columns>
                        <asp:BoundField DataField="pname" HeaderText="Product Name" />
                        <asp:BoundField DataField="prate" HeaderText="Purchase Rate" />
                        <asp:BoundField DataField="qty" HeaderText="Quantity" />
                        <asp:BoundField DataField="tamt" HeaderText="Total Amount" />
                        <asp:BoundField DataField="spamt" HeaderText="Selling Price" />
                     </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr align="center">
                <td colspan="4">
                <center>
                <asp:ImageButton id="prbtnadd" runat="server" ImageUrl="~/admin/Images/addbtnrose.png" Height="50px"  önClick="prbtnadd_Click"></asp:ImageButton>
                <asp:ImageButton id="prbtnsave" runat="server" ImageUrl="~/admin/Images/savebtnrose.png" Height="50px"></asp:ImageButton>
                <asp:ImageButton id="prbtnedit" runat="server" ImageUrl="~/admin/Images/editbtnrose.png" Height="50px"></asp:ImageButton>
                <asp:ImageButton id="prbtndelete" runat="server" ImageUrl="~/admin/Images/deletebtnrose.png" Height="50px"></asp:ImageButton>
                </center>
               </td>
            </tr>
</ContentTemplate>
</Ajax:TabPanel>
</Ajax:TabContainer>

推荐答案

您可以继续在相同的过程中在同一个表中插入数据使用不同的插入命令。
You can go ahead and insert data in the same table in the same procedure with different insert commands.




在存储过程中,您可以有多个查询,没有问题。

但是我我认为您需要规范化您的表格,但仍然可以按照您提到的方式输入值而不会出现任何错误。
Hi,
In stored procedure you can have multiple queries, no issue with that.
But I think you need to normalize your table but still you can enter values the way you mentioned without any error.


通过对数据库,数据规范化和存储的一些了解,您将获益匪浅。程序等



应用程序的效率与使用的数据结构一样高效。例如,如果数据结构未正确规范化,则检索数据将成为问题和错误。这将导致整个应用程序执行不良。在硬币的另一面,有一个非常好的数据结构,即使是一个非常糟糕的用户界面也可以合理地哼唱。 (显然我不会推广糟糕的前端代码,因为那只会很愚蠢。写好双方。)
You would benefit greatly from doing a little learning about databases, normalization of data, and stored procedures, etc.

An application is only as efficient as the data structure used. For example, if the data structure is not normalized properly then retrieving data will become problematic and buggy. That will cause the entire application to perform badly. On the other side of the coin, with a really good data structure, even a really crappy UI can hum along reasonably well. (Obviously I'm not promoting bad front end code because that would just be silly. Write both sides well.)


这篇关于Sql存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆