I got a table with company details.I am using ODBC to conect to it.
I am writing a windows form application in C# 2005 express edition.The task is to search companies. my code is as below.
OdbcCommand cmd = new OdbcCommand("use company", MyConnection);
cmd.CommandText = "SELECT * FROM employee WHERE Name = ?;"; /****line 3*****/
cmd.Parameters.Add("@.Name", OdbcType.VarChar, 30);
cmd.Parameters["@.Name"].Value = textBox1.Text;
cmd.ExecuteNonQuery();
OdbcDataAdapter datadapter = new OdbcDataAdapter(cmd.CommandText, MyConnection);
DataSet dataset = new DataSet();
datadapter.Fill(dataset,"employee"); /**error line***/
dataGridView1.DataMember="employee";
dataGridView1.DataSource=dataset;
The above code compiles cleanly but when you run it,it gives a error. the error statemnet is as below and the line giving error is show above in coment.
ERROR [07002] [MySQL][ODBC 3.51 Driver][mysqld-5.0.27-community-nt]SQLBindParameter not used for all parameters
When line 3 is replaced by cmd.CommandText = "SELECT * FROM employee;"; the program works. fine.
I can view all employees only.BUT not a specific employee.
the problem looks complex.If some-one can help me out,it would be much appreciated.
Thanx
Rahul SK
msn add:ar_kul@.hotmail.comDo you sure that 'Name' field is exists in this table?
sql
No comments:
Post a Comment