User-256597427 posted
Let me Send you full CODE then. Please Let me know where I am going Wrong. Hope you help me to get rid of this problem. Code as follows
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace Iselibrary
{
public partial class Delete : Form
{
SqlConnection vid = new SqlConnection("Data Source=.;Initial Catalog=iselibrary;Integrated Security=True");
//private object item;
public Delete()
{
InitializeComponent();
}
private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
{
}
private void button1_Click_1(object sender, EventArgs e)
{
this.Close();
Home home = new Home();
home.Show();
}
private void Update_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'iselibraryDataSet1.T_BOOK_ISSUE_TABLE' table. You can move, or remove it, as needed.
this.t_BOOK_ISSUE_TABLETableAdapter.Fill(this.iselibraryDataSet1.T_BOOK_ISSUE_TABLE);
}
private void button2_Click(object sender, EventArgs e)
{
String str = "Select * from T_BOOK_ISSUE_TABLE where (USN like '%' + @search + '%')";
SqlCommand xp = new SqlCommand(str, vid);
xp.Parameters.Add("@search", SqlDbType.NVarChar).Value = textBox1.Text;
vid.Open();
xp.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = xp;
DataSet dat = new DataSet();
da.Fill(dat, "USN");
dataGridView1.DataSource = dat;
dataGridView1.DataSource = dat.Tables[0];
vid.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
// Delete Button Details//
private void button3_Click(object sender, EventArgs e)
{
iselibraryEntities ise = new iselibraryEntities();
foreach (var item in dataGridView1.Rows)
{
DataGridViewRow row = item as DataGridViewRow;
if (row.Selected)
{
string usn = row.Cells["USN"].Value.ToString();
var issu = ise.T_BOOK_ISSUE_TABLE.FirstOrDefault(a => a.USN.Equals(usn));
if (issu != null)
{
ise.T_BOOK_ISSUE_TABLE.remove
}
}
}
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}
THANK YOU