Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Answers
What is wrong?
Goran Bibic
6y
147
1
Reply
private
void
button4_Click(object sender, EventArgs e)
{
if
(bar_code1DataGridView.SelectedRows.Count > 0)
{
DataGridViewRow dr = bar_code1DataGridView.SelectedRows[0];
if
(!string.IsNullOrEmpty(dr.Cells[
"dataGridViewTextBoxColumn1"
].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"
, 0);
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();
}
}
}
}
}
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
How To send Email to all Registered User E-mail ID in ASP C#
Open new window using ASP.Net without hitting popup blocker