I am pretty new at C# and .NET, but I've made this code to call a stored procedure, and I then want to take the returned DataTable and convert it to JSON.
SqlConnection con = new SqlConnection("connection string here");
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand("getDates", con);
SqlParameter par = new SqlParameter("@PlaceID", SqlDbType.Int);
par.Value = 42;
da.SelectCommand = cmd;
cmd.Parameters.Add(par);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
con.Open();
try{
cmd.CommandType = CommandType.StoredProcedure;
da.Fill(ds);
}
My question then is what is the best/simplest way to do that? An example would be great as I'm still very new to this.