I have 3 error and I can't manage this. Please, help me to solve them.
Thanks,
Raul
Severity Code Description Project File Line Suppression State Error CS0029 Cannot implicitly convert type 'System.Data.SqlClient.SqlCommand' to 'System.Data.SqlClient.SqlConnection' Website
Severity Code Description Project File Line Suppression State Error CS1061 'SqlConnection' does not contain a definition for
'CommandText' and no extension method 'CommandText' accepting a first argument of type 'SqlConnection' could be found (are you missing a
using directive or an assembly reference?)Severity Code Description Project File Line Suppression State Error CS1061 'SqlConnection' does not contain a definition for
'ExecuteReader' and no extension method 'ExecuteReader' accepting a
first argument of type 'SqlConnection' could be found (are you
missing a using directive or an assembly reference?) Website
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Collections;
namespace Website
{
public static class ConnectionClass
{
private static SqlConnection conn;
private static SqlConnection command;
static ConnectionClass()
{
string connectionString = ConfigurationManager.ConnectionStrings["tigariConnection"].ToString();
conn = new SqlConnection(connectionString);
command = new SqlCommand("",conn);
}
public static ArrayList GetTigariByType(string tigariType)
{
ArrayList list = new ArrayList();
string query = string.Format("SELECT * FROM tigari WHERE type LIKE '{0}'", tigariType);
try
{
conn.Open();
command.CommandText = query;
SqlDataReader reader = command.ExecuteReader();
while(reader.Read())
{
int id = reader.GetInt32(0);
string name = reader.GetString(1);
string type = reader.GetString(2);
double price = reader.GetDouble(3);
string country = reader.GetString(4);
string image = reader.GetString(5);
string review = reader.GetString(6);
Tigari tigari = new Tigari(id, name, type, price, country, image, review);
list.Add(tigari);
}
}
finally
{
conn.Close();
}
return list;
}
}
}