Created
May 2, 2016 12:49
-
-
Save anonymous/4fbf5fd1e91ebf336b4cebacad5e2ccc 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 SearchLog(Logbook searchParameters) // this is the search method. | |
{ | |
try | |
{ | |
int result; | |
string connection = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Databas.mdf;Integrated Security=True;Connect Timeout=30"; | |
using (SqlConnection conn = new SqlConnection(connection)) | |
{ | |
conn.Open(); | |
string sqlQuery = string.Format("Select name, title, text, date from lb WHERE {0} like @search", searchParameters.GetComboBox()); | |
SqlDataAdapter sda = new SqlDataAdapter(sqlQuery, conn); | |
sda.SelectCommand.Parameters.AddWithValue("@search", "%" + searchParameters.GetSearchWord()); | |
DataTable dt = new DataTable(); | |
sda.Fill(dt); | |
dataGridView1.DataSource = dt; | |
searchResult = dataGridView1.RowCount; | |
return searchResult; | |
} | |
} | |
// when creating a remove from database method. Should I use the return value into another query or what would be the best way? | |
DatabaseDataSet = | |
UL L U | |
lid(fk) lid(pk) uid(pk) | |
uid(fk) usr fn | |
pw ln | |
pid | |
But in database I have one more table LB (lbid, name, title, text, date) | |
Should I connect these or what? Because the LB table is not visible in DatabaseDataSet? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment