程序
create procedure select
@activity
as
Begin
Select Count(UserID) FROM users where Status = @activity
end
C#頁面加載
string activity1="active";
string activity2="Inactive";
sqlconnection con=new sqlconnection("give your connection string");
sqlcommand cmd=new sqlcommand();
cmd=new sqlcommand("select",con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@activity",activity1);
String result1=cmd.ExecuteNonQuery();
sqlcommand cmd1=new sqlcommand();
cmd1=new sqlcommand("select",con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.AddWithValue("@activity",activity2);
String result2=cmd.ExecuteNonQuery();
Label1.Text=result1;
Label2.Text=result2;
.aspx頁面中
歡迎到我的主頁 目前有<asp:label id="Label1" runat="server"></asp:Label>
用戶活躍我的頁面和<asp:label id="Label2" runat="server"></asp:Label>
處於非活動狀態。 如果你覺得這很有用,它解決了你的問題,將其標記爲答案並放棄。