public DataTable GetData(int from_month, int to_month) { int year = DateTime.Now.Year; DataTable dt = new DataTable(); SqlConnection con = new SqlConnection(sWebCon); SqlCommand com = new SqlCommand(); com.Connection = con; com.CommandType = CommandType.StoredProcedure; com.CommandText = "usp_tbl_losses"; SqlParameter prm_yearl = new SqlParameter("@year", SqlDbType.Int); prm_yearl.Value = year; com.Parameters.Add(prm_yearl); SqlParameter prm_from_monthl = new SqlParameter("@from_month", SqlDbType.Int); prm_from_monthl.Value = from_month; com.Parameters.Add(prm_from_monthl); SqlParameter prm_to_monthl = new SqlParameter("@to_month", SqlDbType.Int); prm_to_monthl.Value = to_month; com.Parameters.Add(prm_to_monthl); try { con.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = com; da.Fill(dt); } catch (Exception ex) { if (con.State == ConnectionState.Open) { con.Close(); } dt = null; } finally { con.Close(); } return dt; }
<script type="text/javascript"> var fromMonth , toMonth; function GetData() { fromMonth = document.getElementById('txt_from').value; toMonth = document.getElementById('txt_to').value; // I need to read returned data table below WebService.GetData(fromMonth, toMonth, oncomplate,onfailed); } function oncomplate() { alert("this worked"); } function onfailed() { alert("error"); } </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)