asp reader() mysql,MysqlDataReader不适用于asp.net(c#)

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值