How to solve the problem ?
Error 1 'System.Data.OleDb.OleDbDataReader' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.OleDb.OleDbDataReader' could be found (are you missing a using directive or an assembly reference?)
public partial class Default2 : System.Web.UI.Page
{
System.Data.OleDb.OleDbConnection Con = new System.Data.OleDb.OleDbConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings("MyConnectionString").ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
OleDbCommand cmd2 = new OleDbCommand("select Q,a1,a2,a3,a4 from ope", Con);
Con.Open();
OleDbDataReader dr = cmd2.ExecuteReader();
if (dr.Read())
{
Label2.Text = dr[0].ToString();
RadioButton1.Text = dr[1].ToString();
RadioButton2.Text = dr[2].ToString();
RadioButton3.Text = dr[3].ToString();
RadioButton4.Text = dr[4].ToString();
}
Con.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
if (RadioButton1.Checked == false && RadioButton2.Checked == false && RadioButton3.Checked == false && RadioButton4.Checked == false)
{
return;
}
//Try
// If Request.Cookies("vv").Value = "t" Then
// Label3.Visible = True
// Exit Sub
// End If
//Catch ex As Exception
//End Try
byte x = 0;
byte[] y = new byte[4];
if (RadioButton1.Checked) { x = 0; goto x; }
if (RadioButton2.Checked) { x = 1; goto x; }
if (RadioButton3.Checked) { x = 2; goto x; }
if (RadioButton4.Checked)
x = 3;
x:
OleDbCommand cmd = new OleDbCommand("select r1,r2,r3,r4 from ope", Con);
Con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
y[0] = dr.Item[0];
y[1] = dr.Item[1];
y[2] = dr.Item[2];
y[3] = dr.Item[3];
}
dr.Close();
Con.Close();
y[x] += 1;
OleDbCommand cmd2 = new OleDbCommand("update ope set r" + Convert.ToString(x + 1) + " = " + Convert.ToString(y[x]), Con);
int updated = 0;
Con.Open();
updated = cmd2.ExecuteNonQuery();
Con.Close();
Panel1.Visible = false;
Panelxxx.Visible = true;
// '==================================================
//'==================================================
int tx = y[0] + y[1] + y[2] + y[3];
rr1.Text = RadioButton1.Text;
rr2.Text = RadioButton2.Text;
rr3.Text = RadioButton3.Text;
rr4.Text = RadioButton4.Text;
v1.Text = Convert.ToString(y[0]) + "صوت";
h1.Text = Convert.ToString(Convert.ToInt32((y[0] / tx) * 100));
Image1.Width = Convert.ToInt32(h1.Text * 2);
v2.Text = Convert.ToString(y[1]) + "صوت";
h2.Text = Convert.ToString(Convert.ToInt32((y[1] / tx) * 100));
Image2.Width = Convert.ToInt32(h2.Text * 2);
v3.Text = Convert.ToString(y[2]) + "صوت";
h3.Text = Convert.ToString(Convert.ToInt32((y[2] / tx) * 100));
Image3.Width = Convert.ToInt32(h3.Text * 2);
v4.Text = Convert.ToString(y[3]) + "صوت";
h4.Text = Convert.ToString(Convert.ToInt32((y[3] / tx) * 100));
Image4.Width = Convert.ToInt32(h4.Text * 2);
HttpCookie ck1 = new HttpCookie("vv", "t");
Response.Cookies.Add(ck1);
ck1.Expires = DateAndTime.Now.AddDays(20);
}
}