Created
May 2, 2016 20:14
-
-
Save anonymous/dce0044a41fa84f8b44ca4de3a30cdc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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