自由国度

.Net、C#、WPF、Silverlight、HTML5、JavaScript等,好好写代码。

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
 1using System;
 2using System.Collections.Generic;
 3using System.Linq;
 4using System.Text;
 5using System.Threading;
 6using System.Data;
 7using System.Data.SqlClient;
 8namespace ConsoleApplicationTest
 9{
10    class Program
11    {
12        static void Main(string[] args)
13        {
14            try
15            {
16                //connection对象
17                string strConn = "Data Source=.;uid=sa;pwd=wzb0227;Integrated Security=SSPI;Initial Catalog=Evaluation;Integrated Security=True";
18                SqlConnection conn = new SqlConnection(strConn);
19                conn.Open();
20                //command对象
21                SqlCommand comm = new SqlCommand("getCountNum", conn);
22                comm.CommandType = CommandType.StoredProcedure;
23                //填充参数
24                SqlParameter para = new SqlParameter("@count", SqlDbType.Int);
25                para.Direction = ParameterDirection.Output;
26                comm.Parameters.Add(para);
27                //执行,取输出参数
28                comm.ExecuteNonQuery();
29                int count = (int)comm.Parameters["@count"].Value;
30                conn.Close();
31                Console.WriteLine("count=" + count);
32            }

33            catch
34            {
35                Console.WriteLine("出现了异常!");
36            }

37        }

38    }

39}
posted on 2008-12-19 10:57  彬子  阅读(1904)  评论(0编辑  收藏  举报