学习中看到的一个调用存储过程的例子。初学者非常适合.

 

            string conn="server=127.0.0.1;UID=qgf;PWD=happyness820912;Database=ClientManage";// 在此处放置用户代码以初始化页面
            System.Data.SqlClient.SqlConnection StrSelect=new System.Data.SqlClient.SqlConnection(conn);// 在此处放置用户代码以初始化页面
            System.Data.SqlClient.SqlCommand Qgf_sqlcommand=new System.Data.SqlClient.SqlCommand();
            Qgf_sqlcommand.CommandText
="Test";
            Qgf_sqlcommand.CommandType
=System.Data.CommandType.StoredProcedure;
            Qgf_sqlcommand.Connection
=StrSelect;
            Qgf_sqlcommand.Parameters.Add(
"@Perid",SqlDbType.Int,4);
            Qgf_sqlcommand.Parameters[
"@Perid"].Direction=ParameterDirection.Output;
            Qgf_sqlcommand.Parameters.Add(
"@z_dutyname",SqlDbType.NVarChar,50);
            Qgf_sqlcommand.Parameters[
"@z_dutyname"].Direction=ParameterDirection.Output;
            Qgf_sqlcommand.Parameters.Add(
"@id",SqlDbType.Int,4);
            Qgf_sqlcommand.Parameters[
"@id"].Value=1;
            StrSelect.Open();
            Qgf_sqlcommand.ExecuteNonQuery();
            Response.Write(Qgf_sqlcommand.Parameters[
"@z_dutyname"].Value);
不用多解释吧...这个冬冬是灵魂..8错8错
posted @ 2005-12-30 23:17  风谷.Net  阅读(243)  评论(0编辑  收藏  举报