Skip to content

Instantly share code, notes, and snippets.

Created May 2, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/dce0044a41fa84f8b44ca4de3a30cdc4 to your computer and use it in GitHub Desktop.
Save anonymous/dce0044a41fa84f8b44ca4de3a30cdc4 to your computer and use it in GitHub Desktop.
private int RemoveLog(Logbook parameters) // radera inlägg
{
try
{
int removeResult;
string connection = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Databas.mdf;Integrated Security=True;Connect Timeout=30";
SqlConnection con = new SqlConnection();
using (SqlConnection conn = new SqlConnection(connection))
{
conn.Open();
string sqlQuery = string.Format("DELETE FROM lb WHERE {0} like @search", parameters.GetComboBox());
SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, conn);
sda.SelectCommand.Parameters.AddWithValue("@search", "%" + parameters.GetSearchWord());
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView2.DataSource = dt;
removeResult = dataGridView2.RowCount;
return removeResult;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment