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
Goran Bibic
480
2.9k
200.7k
What is wrong here?
Jan 24 2018 3:11 PM
private void delete_button4_Click(object sender, EventArgs e)
{
if (bar_code1DataGridView.SelectedRows.Count > 0)
{
DataGridViewRow dr = bar_code1DataGridView.SelectedRows[0];
if (string.IsNullOrEmpty(dr.Cells["id"].Value.ToString()))
{
String cs = "Data Source=.\\SQLEXPRESS;Initial Catalog=barcode;Integrated Security=True";
using (SqlConnection openCon = new SqlConnection(cs))
{
using (SqlCommand querySaveStaff = new SqlCommand("DELETE FROM bar_code1 WHERE id=@id", openCon))
{
// querySaveStaff.Parameters.Add("@id",SqlDbType.Int).Value=idTextBox.Text;
querySaveStaff.Parameters.AddWithValue("@id", 1);
openCon.Open();
querySaveStaff.ExecuteNonQuery();
openCon.Close();
}
}
using (SqlConnection openCon = new SqlConnection(cs))
{
string saveStaff = "SELECT * FROM dbo.bar_code1 ";
openCon.Open();
using (SqlDataAdapter querySaveStaff = new SqlDataAdapter(saveStaff, cs))
{
querySaveStaff.Fill(barcodeDataSet.bar_code1);
bar_code1DataGridView.DataSource = barcodeDataSet.bar_code1;
bar_code1DataGridView.Update();
bar_code1DataGridView.Refresh();
}
}
}
}
}
Reply
Answers (
5
)
showing a default value in Drop Down in MVC
how to create a partial page in Asp.net for Creating online