C#和MySQL的问题...! [英] c# and Mysql problem...!
本文介绍了C#和MySQL的问题...!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的应用程序(Windows窗体)中有一个datagridview,并且在mysql中有一个带有某些成员的数据库.在我的Windows窗体中,我还有一个文本框.我需要的所有代码是,当我在文本框中编写字符示例"L"时,然后在datagirdview中列出所有带有"L"的名称.因此,此文本框必须与mysql相关....我需要相应的代码.
也许这些可以帮助您帮助我,这是sql的代码,我需要mysql
I have a datagridview in my application(windows form)and I have a database with some members in mysql. In my windows form I also have a textbox. All what I need is code that when I write the character example ''L'' in a textbox then in datagirdview to be listed all names with ''L''. So this textbox must be related with mysql .... I need a code for that.
Maybe these can help you to help me, this is a code for sql, I need for mysql
private DataSet LexoShenimet(string _strQuery)
{
DataSet dsShenimet = new DataSet();
string _strKonektimiMeDB = "";
_strKonektimiMeDB = ConfigurationManager.ConnectionStrings["Aplikacion.Properties.Settings.dbBIBLOTEKAConnectionString1"].ConnectionString;
SqlConnection sqlKonektimi = new SqlConnection(_strKonektimiMeDB);
SqlDataAdapter sqlAdapteri = new SqlDataAdapter(_strQuery, _strKonektimiMeDB);
try
{
sqlKonektimi.Open();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
sqlKonektimi.Close();
return null;
}
sqlAdapteri.Fill(dsShenimet);
sqlKonektimi.Close();
return dsShenimet;
}
private void txtkerko_TextChanged(object sender, EventArgs e)
{
DataSet dsShenimet = new DataSet();
string _strQuery = "";
_strQuery = "SELECT * FROM tblBibloteka WHERE Emri Like '%" + txtKerko.Text + "%'";
dsShenimet = this.LexoShenimet(_strQuery);
dgvLista.DataSource = dsShenimet.Tables[0].DefaultView;
dgvLista.Columns["Mbiemri"].Visible = true;
}
推荐答案
看看如何过滤DGV:
Have a look at filtering a DGV: http://social.msdn.microsoft.com/forums/en-US/vblanguage/thread/985dfdc7-e7a7-496a-be54-8c03a20913fd[^] - you don''t need to reselect the data each time, you can control the viewed data instead.
这篇关于C#和MySQL的问题...!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文