Hi @fahimahmed,
Try this sample..
Html.
<div>
Min Range:<asp:TextBox ID="txtMinRange" runat="server" /><br />
Max Range:
<asp:TextBox ID="txtMaxRange" runat="server"></asp:TextBox>
<br />
<asp:Button Text="Save" runat="server" OnClick="Save" />
</div>
Code
protected void Save(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString);
for (int minRange = int.Parse(this.txtMinRange.Text.Trim()); minRange <= int.Parse(this.txtMaxRange.Text.Trim()); minRange++)
{
SqlCommand cmd = new SqlCommand("INSERT INTO SeriesRecords VALUES(@Id,@Series)", con);
con.Open();
cmd.Parameters.AddWithValue("@Id", minRange);
cmd.Parameters.AddWithValue("@Series", minRange);
cmd.ExecuteNonQuery();
con.Close();
}
}
Namespaces
using System;
using System.Data.SqlClient;
using System.Configuration;
Warm Regards:-