Hello,
I have a WebService that gets a LessonID and returns a list<string> that has all the links of the lesson from access database:
[WebMethod]
public List<string> Lessons(int lessonID)
{
string lessonsource = "";
string cs = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source= " + GetDBLocation();
OleDbConnection cl = new OleDbConnection(cs);
string ssql = "SELECT Lesson.Lesson_ID, Lesson.Lesson_Source FROM Lesson WHERE (((Lesson.Lesson_ID)=" + lessonID + "));";
OleDbCommand myCmd = new OleDbCommand(ssql, cl);
OleDbDataReader dr = null;
try
{
cl.Open();
dr = myCmd.ExecuteReader();
while (dr.Read())
{
lessonsource = dr["Lesson_Source"].ToString();
//Lesson_Source has the path to the .txt file
}
}
catch (Exception err)
{
}
finally
{
dr.Close();
cl.Close();
}
StreamReader reader = new StreamReader(lessonsource);
string line = "";
List<string> list = new List<string>();
while ((line = reader.ReadLine()) != null)
list.Add(line);
reader.Close();
return list;
}
I use it this way:
List<string> list = new List<string>();
Web_Services.Service1 ws = new TeoryWebSite.Web_Services.Service1();
list = ws.Lessons(lessonID);
I get an error on "ws.Lessons(lessonID)":
Cannot implicitly convert type 'string[]' to 'System.Collections.Generic.List<string>'
Why is that happening?
Thanks.