TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ankit gaur
1.4k
298
32.8k
ParameterId is not inserting in a incremental order in sql
Aug 1 2018 4:52 AM
My C# code
private string AutoIncrementID()
{
SqlConnection con = new SqlConnection();
myconn.Open();
SqlCommand cmd = new SqlCommand("Select *,ParameterId = 'P' + convert(varchar(10),row_number() over (partition by ItemId order by ParaId)) from tblMatParameter", myconn);
SqlDataReader dr = cmd.ExecuteReader();
string ParameterId = null;
if (dr.Read())
{
ParameterId = dr[0].ToString();
myconn.Close();
}
return ParameterId;
}
protected void Save(object sender, EventArgs e)
{
foreach (GridViewRow gvr in Gridview1.Rows)
{
//Connection
TextBox Parameter = gvr.FindControl("txtPara") as TextBox;
string txtPara = Parameter.Text;
string ParameterId = AutoIncrementID();
//int idLimit = 2;
string ParaNo = "" + ("P" + ParameterId);
SqlCommand cmd = new SqlCommand("INSERT INTO [ElixirERP].[ElixirAdmin].[tblMatParameter](ParameterId,Category,SubCategory,Brand,Item,Parameter,ItemId)" +
"VALUES('" + ParaNo + "',@ddlCategory,@ddlSubCategory,@ddlBrand,@ddlItem,'" + txtPara + "',(Select ItemId From [ElixirERP].[ElixirAdmin].[tblMatItem] where ItemId = '" + ddlItem.SelectedValue + "'))");
Sql Table
Reply
Answers (
6
)
set height dynamically in RDLC report for thermal printer
What module need to include in user management web applicati