将多行插入数据库&可以放在循环部分中 [英] inserting the multiple rows into the database & that can be placed as in a looping section

查看:92
本文介绍了将多行插入数据库&可以放在循环部分中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

插入txtUname.text作为sql命令的参数时
代替Web控件ID(分配给数组),我们可以在sql命令中使用Uname [index] .text之类的数组.

如果还没有一个人知道这个问题,请给我答复?我会解释我想要什么?
请帮助我........

while inserting the txtUname.text as an argument for the sql command
in place of the web control id(assigned to a array) can we use an array like Uname[index].text in the sql command.

If yet all any one didn''t get idea of this question please give me a reply? i''ll explain what i want?
Please help me........

推荐答案



我为您编写了一些代码.请一次检查

也许这就是您想要的

Hi,

I write some code for you.check this once

May be this is what you want

<asp:panel id="Panel1" runat="server" xmlns:asp="#unknown">
    <asp:textbox id="TextBox1" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox2" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox3" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox4" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox5" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox6" runat="server"></asp:textbox><br />
</asp:panel>
<br />
<asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" xmlns:asp="#unknown" />



文件后面的代码包含以下代码



And code behind file contains following code

    protected void Button1_Click(object sender, EventArgs e)
    {
        List<textbox> txtboxlst = new List<textbox>();
        foreach (Control c in Panel1.Controls)
        {
            if (c is TextBox)
            {
                txtboxlst.Add((TextBox )c);
            }
        }
        string str1 = txtboxlst[0].Text;
    }
</textbox></textbox>




现在告诉我你到底想要什么

最好的




Now tell me what exactly you want

All the Best



首先,将Children的所有详细信息存储在Temp Datatable中
说Dt ...
现在您可以访问dt的每个单元格,因此您可以将此详细信息存储在相应的数据库表中
Hi,
First Of all take All the details Of Children And Store it in Temp Datatable
Say Dt...
Now You can Access Each cell of dt Accordingly you can store this Details In Respective Database Table
table = (DataTable)Session["Temp_Product_Table"];

                     for (int i = 0; i < table.Rows.Count; i++)
                     {
                         string cmd_Insert_Product_In_Db = "INSERT INTO IWO_Product_List(iwo_no,product,model,price,vat,excise,other_tax,amount) Values('" + table.Rows[i][1] + "','" + table.Rows[i][2] + "','" + table.Rows[i][3] + "','" + table.Rows[i][4] + "','" + table.Rows[i][5] + "','" + table.Rows[i][6] + "','" + table.Rows[i][7] + "','" + table.Rows[i][8] + "')";
                         MIS_DAL.ExecuteNonQuery(cmd_Insert_Product_In_Db, "query");

                     }


这篇关于将多行插入数据库&amp;可以放在循环部分中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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