本文介绍了它只显示列但数据没有出现......?请帮帮我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public partial class Window_search:Window
{
public Window_search()
{
InitializeComponent();
}
private void Search_button_Click_1(对象发送者,RoutedEventArgs e)
{
var id = Device_id_TextBox.ToString();
MySqlConnection con = new MySqlConnection(database);
con.Open();
DataTable devicetable = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter(SELECT`Device_ID`,`Device_Name`,`Devic_Category`,`Status`,`Description`,`Customer_ID`,`Customer_Name` FROM`devicedetails` WHERE`Device_ID` ='id ,CON);
尝试
{
adapter.Fill(devicetable);
table_grid_view.DataContext = devicetable;
con.Close();
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
< pre lang = c#>< pre lang = c# >
我尝试过:
公共部分类Window_search:Window
{
public Window_search()
{
InitializeComponent();
}
private void Search_button_Click_1(对象发送者,RoutedEventArgs e)
{
var id = Device_id_TextBox.ToString();
MySqlConnection con = new MySqlConnection(database);
con.Open();
DataTable devicetable = new DataTable();
MySqlDataAdapter adapter = new MySqlDataAdapter(SELECT`Device_ID`,`Device_Name`,`Devic_Category`,`Status`,`Description`,`Customer_ID`,`Customer_Name` FROM`devicedetails` WHERE`Device_ID` ='id ,CON);
尝试
{
adapter.Fill(devicetable);
table_grid_view.DataContext = devicetable;
con.Close();
}
catch(Exception Ex)
{
MessageBox.Show(Ex.Message);
}
}
}
解决方案
public partial class Window_search : Window { public Window_search() { InitializeComponent(); } private void Search_button_Click_1(object sender, RoutedEventArgs e) { var id = Device_id_TextBox.ToString(); MySqlConnection con = new MySqlConnection("database"); con.Open(); DataTable devicetable = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT `Device_ID`, `Device_Name`, `Devic_Category`, `Status`, `Description`, `Customer_ID`, `Customer_Name` FROM `devicedetails` WHERE `Device_ID` = 'id'",con); try { adapter.Fill(devicetable); table_grid_view.DataContext = devicetable; con.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } } }
<pre lang="c#"><pre lang="c#">
What I have tried:
public partial class Window_search : Window { public Window_search() { InitializeComponent(); } private void Search_button_Click_1(object sender, RoutedEventArgs e) { var id = Device_id_TextBox.ToString(); MySqlConnection con = new MySqlConnection("database"); con.Open(); DataTable devicetable = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter("SELECT `Device_ID`, `Device_Name`, `Devic_Category`, `Status`, `Description`, `Customer_ID`, `Customer_Name` FROM `devicedetails` WHERE `Device_ID` = 'id'",con); try { adapter.Fill(devicetable); table_grid_view.DataContext = devicetable; con.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } } }
解决方案
这篇关于它只显示列但数据没有出现......?请帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!