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
Durga Velusamy
NA
318
114.4k
find the error
Apr 15 2015 3:37 AM
The below code does not work. Its shows an error as item collections cannot be modified.
Last 5
th
line error. Why its shows an error?
I have to get the count value of last id +1 on combobox1.when execute the application it create the id but I did not able to get it in combobox1. Please find.
private
void
button2_Click(
object
sender,
EventArgs
e)
{
int
CustomerId=0;
int
i=0;
SqlConnection
con =
new
SqlConnection
(
@"server=CSE-PC; integrated security=true; Database=Bas"
);
con.Open();
SqlCommand
com =
new
SqlCommand
(
"select max(CustomerId) FROM devi"
, con);
if
(com.ExecuteScalar().ToString() ==
""
)
{
CustomerId = 0;
}
else
{
CustomerId =
int
.Parse(com.ExecuteScalar().ToString());
}
if
(CustomerId > 0)
{
CustomerId = CustomerId + 1;
}
else
{
CustomerId = 001;
}
if
(i>0)
{
CustomerId = CustomerId + 1;
}
else
{
CustomerId = 001;
}
comboBox1.Items.Add("CustomerId");
/* collections cannot be modified */
i = i + 1;
MessageBox
.Show(
"IdCreated"
);
con.Close();
}
Reply
Answers (
2
)
I have a task to read a excel file using asp.net.
how to get textbox two or more address