私のプロジェクトの1つでは、C#を使用してTextBoxで次の手順で返された値を読み取る必要があります。
c#を使用して次の手順で返されたTextBoxで@aを読み取るコードを誰でも書くことができますか??
create procedure [dbo].[Test]
as
declare
@a numeric(5)
begin
set @a = (select COUNT(*) from Emp);
return @a
end
私はこれを試しました
SqlConnection cn = new SqlConnection("data source=localhost;initial catalog=acc;uid=sa;pwd=fantastic");
cn.Open();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Test";
Int32 i = Convert.ToInt32(cmd.ExecuteScalar());
textBox1.Text = i.ToString();