You are on page 1of 2

(1)

public DataSet GetGenre()


{
try
{
Database objDatabase = GetDatabase();
using (DbCommand cmd = objDatabase.GetStoredProcCommand("BGM_Get
AllGenres"))
{
//objDatabase.AddInParameter(cmd, "@search", DbType.String,
searchstring);
DataSet ds = objDatabase.ExecuteDataSet(cmd);
return ds;
}
}
catch (Exception ex)
{
throw ex;
}

(2)

public void GetAllUsers()


{
SqlConnection con = null;
SqlCommand cmd = null;
con = new SqlConnection();
cmd = new SqlCommand();
con.ConnectionString = ConfigurationManager.ConnectionStrings["PostA
ngularJS"].ConnectionString;
try
{
con.Open();
cmd = new SqlCommand("spSavetblUser", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", HttpContext.Current.Req
uest.Form["UserName"].ToString());
cmd.Parameters.AddWithValue("@Password", HttpContext.Current.Req
uest.Form["Password"].ToString());
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DatatableToJson(ds.Tables[0]);

JavaScriptSerializer js = new JavaScriptSerializer();


string json = js.Serialize(DatatableToJson(ds.Tables[0]));
this.Context.Response.ContentType = "application/json; charset=u
tf-8"; // Changing the type of XML format to charset=utf-8
this.Context.Response.Write(json);
}

// Json Procedure ends


catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Dispose();
con.Close();
}
}
(3)
public JsonResult getallgenre()
{
DataSet ds = mFac.GetGenre();
string json = DatatableToJson(ds.Tables[0]);
return Json(json, JsonRequestBehavior.AllowGet);
}

You might also like