Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all articles
Browse latest Browse all 1451

AutoComplete Function problem (1 reply)

$
0
0
Hello guys,
I'm developing a Data Driven website using Visual Studio 2008 and Backend as out Favorite Mysql.
I want to design a function for search in the table which will be used for Ajax Extender purpose,for WebService purpose.
the table description of company Table

Field DataType
-------------------------
companyid int(11)
company varchar(60)

Data is
companyid company
1 ALEMAC
2 LIVON
5 VIZA

when i query
"SELECT * FROM `company` WHERE `company` LIKE '%vi%'" Data sown in PhpmyAdmin.


Now in the coding i had used this

public DataTable GetCompanyName(string strName)
{
string strConn = ConfigurationManager.ConnectionStrings["MahaveerConnectionString"].ConnectionString;
MySqlConnection con = new MySqlConnection(strConn);
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;//MySql.Data.
cmd.CommandText = "SELECT company FROM company WHERE company like '%?company%'";

MySqlParameter param = new MySqlParameter("?company", strName);
cmd.Parameters.Add(param);
DataSet objDs = new DataSet();
MySqlDataAdapter dAdapter = new MySqlDataAdapter();
dAdapter.SelectCommand = cmd;
con.Open();
dAdapter.Fill(objDs);
con.Close();
return objDs.Tables[0];

}

and it will bind the data ,after calling it

protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = GetCompanyName(TextBox1.Text);
GridView1.DataSource = dt;
GridView1.DataBind();

}
table is
The Information of table is
Type Collation Size Overhead
company MyISAM latin1_swedish_ci 2.1 KiB 20 B

It seems that the rows are showing in the backend but in the coding it is not fetching.
Please enlighten me .Thank you for your valuable support.

Viewing all articles
Browse latest Browse all 1451

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>