I have this solution that supposed to insert numbers from 10 to the numbers espicified in the two textbox. That is for example, if i insert 10 in textbox txtfrom then insert 20 in textbox textTo then when i click button insert it will insert number from 100 to 500 into table like below.
ID Numbers
------------------------------
1 10
--------------------------------
2 11
-------------------------------
3 12
--------------------------------
4 13
-------------------------------
5 14
--------------------------------
6 15
-------------------------------
7 16
--------------------------------
8 17
-------------------------------
9 18
--------------------------------
10 19
-------------------------------
11 20
--------------------------------
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("INSERT INTO Teller VALUES (@Numbers)", con))
{
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Numbers", txtfrom.Text.Trim());
cmd.Parameters.AddWithValue("@Numbers", this.txtTo.Text.Trim());
con.Open();
cmd.ExecuteNonQuery();
con.Close();
BindGrid();
}
}
<div class="form-group data-custon-pick data-custom-mg" id="data_5">
<label>Range Insert</label>
<div class="input-daterange input-group" >
<asp:TextBox ID="txtfrom" runat="server" CssClass="form-control" name="start" value="" type="text" Placeholder="From"></asp:TextBox>
<span class="input-group-addon">to</span>
<asp:TextBox ID="txtTo" runat="server" CssClass="form-control" name="end" value="" type="text" Placeholder="To"></asp:TextBox>
</div>
<asp:LinkButton ID="btnInsert" " runat="server" CssClass="btn btn-md btn-primary login-submit-cs" OnClick="btnInsert_Click"> <i class="fa fa-search adminpro-informatio" aria-hidden="true"></i>Insert Numbers </asp:LinkButton>
</div>