I try to call storerprocedure in LINQ but this show error
code
[WebMethod]
public static string search(DateTime fromdate, DateTime todate, string region)
{
try
{
string result = "";
Ts1 ts = new Ts1();
var dq = ts.griddata(fromdate, todate, region);
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Owner", typeof(string));
foreach (var c in dq)
{
dt.Rows.Add(c.ID, c.owner);
}
result = DataSetToJSON(dt);
return result;
}
catch (Exception)
{
throw new Exception();
}
}
public static string DataSetToJSON(DataTable dt)
{
Dictionary<string, object> dict = new Dictionary<string, object>();
object[] arr = new object[dt.Rows.Count + 1];
for (int i = 0; i <= dt.Rows.Count - 1; i++)
{
arr[i] = dt.Rows[i].ItemArray;
}
dict.Add("response", arr);
JavaScriptSerializer json = new JavaScriptSerializer();
return json.Serialize(dict);
}
but this show error on this line
foreach (var c in dq)
foreach statement cannot operate on variables of type 'int' because 'int' does not contain a public definition for 'GetEnumerator'