How should i return a value from hashtable I used a code like
data access layer
SqlConnection connection = new SqlConnection(c on);
SqlCommand cmd = new SqlCommand("sel _data", connection);
cmd.CommandType = CommandType.Sto redProcedure;
SqlDataReader dr;
connection.Open ();
dr = cmd.ExecuteRead er();
while (dr.Read())
{
Hashtable ht = new Hashtable();
ht.Add("1", dr.GetValue(0). ToString());
ht.Add("2", dr.GetValue(1). ToString());
ht.Add("3", dr.GetValue(2). ToString());
}
dr.Close();
connection.Clos e();
return ht;
in business access layer
return d.getdata1();
in presentation layer
Hashtable ht1 = new Hashtable();
ht1 = b.getdata1();
for (int j = 0; j <= ht1.Count - 1; j++)
{
TextBox1.Text = ht1["1"].ToString();
TextBox2.Text = ht1["2"].ToString();
}
I get the error as Error 'ht' conflicts with the declaration 'Dal.ht'
what is the mistake i made? how should one return a value in hash table?
data access layer
SqlConnection connection = new SqlConnection(c on);
SqlCommand cmd = new SqlCommand("sel _data", connection);
cmd.CommandType = CommandType.Sto redProcedure;
SqlDataReader dr;
connection.Open ();
dr = cmd.ExecuteRead er();
while (dr.Read())
{
Hashtable ht = new Hashtable();
ht.Add("1", dr.GetValue(0). ToString());
ht.Add("2", dr.GetValue(1). ToString());
ht.Add("3", dr.GetValue(2). ToString());
}
dr.Close();
connection.Clos e();
return ht;
in business access layer
return d.getdata1();
in presentation layer
Hashtable ht1 = new Hashtable();
ht1 = b.getdata1();
for (int j = 0; j <= ht1.Count - 1; j++)
{
TextBox1.Text = ht1["1"].ToString();
TextBox2.Text = ht1["2"].ToString();
}
I get the error as Error 'ht' conflicts with the declaration 'Dal.ht'
what is the mistake i made? how should one return a value in hash table?
Comment