hi
I am using Mysql database.
Inserting the values of the Checkbox list into into the mysql table is successful, but the below code for retrieving the data has encountered one problem.
MysqlDataReader dr;
The above line is showing error "The type or namespace MysqlDataReader could not be found."
I have already done the reference part for Mysql.Data, still getting the issue.
What could be the problem?
Code below.protected void Button2_Click(object sender, EventArgs e)
{
string connStr = "Server=localhost;Database=mysqldb;Uid=uid;Pwd=******$$;";
string intersts = "";
using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connStr))
{
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.Connection = conn;
//SqlCommand cmd = new SqlCommand("Select Interests from Demo", cn); // Write your Query i have taken as sample
cmd.CommandText = "Select areas from area_of_interests ";
MysqlDataReader dr;
//SqlDataReader dr;
conn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
intersts = dr["Interests"].ToString();
}
conn.Close();
string[] arr = intersts.Split(',');
foreach (ListItem item in this.CheckBoxList1.Items)
{
foreach (string s in arr)
{
if (item.Text == s)
{
item.Selected = true;
}
}
}
}
}
解决方案;";
string intersts = "";
using (MySql.Data.MySqlClient.MySqlConnection conn = new MySql.Data.MySqlClient.MySqlConnection(connStr))
{
MySql.Data.MySqlClient.MySqlCommand cmd = new MySql.Data.MySqlClient.MySqlCommand();
cmd.Connection = conn;
//SqlCommand cmd = new SqlCommand("Select Interests from Demo", cn); // Write your Query i have taken as sample
cmd.CommandText = "Select areas from area_of_interests ";
MysqlDataReader dr;
//SqlDataReader dr;
conn.Open();
dr = cmd.ExecuteReader();
if (dr.Read())
{
intersts = dr["Interests"].ToString();
}
conn.Close();
string[] arr = intersts.Split(',');
foreach (ListItem item in this.CheckBoxList1.Items)
{
foreach (string s in arr)
{
if (item.Text == s)
{
item.Selected = true;
}
}
}
}
}
it should be MySqlClient note that capital S in Sql
c# is case sensitive.
Quote:In Visual Studio, you can work around this by hitting "Control-Space" alot.
This will auto-complete what you're typing, and fix the casing. If you're
already typed "messagebox", and hit "Control-Space" while your cusor is in
there, it'll change it to "MessageBox".
check this forum post[^]
hi All,
There was an issue with adding reference. Once that was fixed, the issue got resolved.
Of course, right case sensitive spelling was also used.
thanks to all.
--bdhkrl.