私はC#と.NETでかなり新しいですが、ストアドプロシージャを呼び出すためにこのコードを作成しました。次に、返されたDataTableを取得して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);
}
私の質問は、それを行うための最良/最も簡単な方法は何ですか?私はまだこれに非常に慣れていないので、例は素晴らしいでしょう。