I have two sets of code, one to take a varilbe and grab info from SQL DB and fill a DS. The other to assign that DS to a local DS in the calling script. The problem I am getting is
Compiler Error Message: CS0266: Cannot implicitly convert type 'object' to 'System.Data.DataSet'. An explicit conversion exists (are you missing a cast?)
But it does not make senst to me since I never call anything an object both varibles are delcared as DataSet types.
Code with error:Code:public static DataSet GetSQLDataSetByQuery(string SQLQuery) { SqlCommand cmd = new SqlCommand(); DataSet ds = new DataSet(); SqlConnection Con = GetCon(); using (Con) { cmd.CommandType = CommandType.Text; cmd.CommandText = SQLQuery; cmd.Connection = Con; SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds, "TResult"); return ds; } }
As you can see in the code everything is a DataSet so I am not sure where the object is coming from.Code:DataSet ds = SQLHelper.GetSQLDataSetByQuery(SQLQuery); DataBind();




Reply With Quote