Exemplo n.º 1
0
        private void SearchInDB(object sender, RoutedEventArgs e)
        {
            string SQLQuery = "SELECT * FROM `literature` WHERE ";
            string connStr  = @"Database = listofsources; Data Source = localhost; User Id = root; Password ="******"")
                {
                    SQLQuery += "`" + win.TableGrid.Columns[i].Header + "` = " + "'" + tb.Text + "' AND ";
                }
            }
            SQLQuery += "replaceme";
            SQLQuery  = SQLQuery.Replace("AND replaceme", "");

            MySqlLib.MySqlData.MySqlExecuteData.MyResultData result = new MySqlLib.MySqlData.MySqlExecuteData.MyResultData();
            result = MySqlLib.MySqlData.MySqlExecuteData.SqlReturnDataset(SQLQuery, connStr);
            if (result.HasError == false)
            {
                win.TableGrid.ItemsSource = result.ResultData.DefaultView;
                win.Activate();
                Close();
            }
            else
            {
                MessageBox.Show(result.ErrorText);
            }
        }
Exemplo n.º 2
0
        private void From_DB(object sender, RoutedEventArgs e)
        {
            string SQLQuery = "SELECT * FROM literature";

            MySqlLib.MySqlData.MySqlExecuteData.MyResultData result = new MySqlLib.MySqlData.MySqlExecuteData.MyResultData();
            result = MySqlLib.MySqlData.MySqlExecuteData.SqlReturnDataset(SQLQuery, connStr);
            if (result.HasError == false)
            {
                SourcesTable win = new SourcesTable();
                win.Show();
                win.Owner = this;
                win.TableGrid.ItemsSource      = result.ResultData.DefaultView;
                win.TableGrid.Columns[6].Width = 183;
            }
            else
            {
                MessageBox.Show("Что-то не так с базой данных", "", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }