惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
腾讯CDC
大猫的无限游戏
大猫的无限游戏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
博客园_首页
F
Fortinet All Blogs
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
H
Help Net Security
博客园 - 【当耐特】
量子位
博客园 - 叶小钗
M
MIT News - Artificial intelligence
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
MyScale Blog
MyScale Blog
爱范儿
爱范儿
The Cloudflare Blog
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog

博客园 - 骚包猪

未在本地计算机上注册“microsoft.ACE.oledb.12.0”提供程序的解决办法 一份详尽的IPC$入侵资料 vlookup通俗解释 show interface counter 红旗linux下查看文件夹大小 Cisco 删除IOS后恢复、重灌ios x61在vista系统中玩wow魔兽世界 显示器驱动程序已停止响应 黑屏 终极解决方案 如何利用foobar2000将ape转aac格式.... ASP.NET执行SQL超时的解决方案 windows 更改IP地址 批处理文件 cmd命令 - 骚包猪 DropdownList绑定 - 骚包猪 - 博客园 关于datagrid鼠标悬停行数突出显示 - 骚包猪 - 博客园 c# ToString() 格式化字符串 - 骚包猪 ASCII 码表 一个检测文件 的small function c#时间格式化字符串详解 关于编码 建立一个基本SQl2000表 如何将txt文档插入sql2000数据库
.Net下调用SqlServer2k存储过程
骚包猪 · 2007-09-29 · via 博客园 - 骚包猪

首先,在SqlServer中创建存储过程,在调用时分为有参数和没有参数两种情况,先就简单的没有参数的情况简要的介绍:

  假设存储过程如下: CREATE PROC SelectAll

  AS

  SELECT * FROM StudentInf

  则此sp的调用如下:

  SqlCommand selectCMD = new SqlCommand(“SelectAll”, conn);

  //conn 为SqlConnection

  selectCMD.CommandType = CommandType.StoredProcedure;

  如果需要将结果集加到某个DataAdapter上,则可如下:

  SqlDataAdapter stuDA = new SqlDataAdapter();

  stuDa.SelectCommand = selectCMD;

  如果有参数:create proc andSelect

  @StudentId varchar(10),

  @StudentName varchar(10),

  As

  Select * from StudentInf where StudentId = @StudentId and StudentName = @StudentName

  则参数可以如下添加:

  selectCMD.Parameters.Add(“@StudentId”, SqlDbType.NVarChar, 10);

  selectCMD.Parameters.Add(“@StudentName”, SqlDbType.NvarChar, 10);

  如果只有一个参数,也可以这样赋值:

  SqlParameters onePara = selectCMD.Parameters.Add(“@StudentId”, SqlDbType.NVarChar, 10);

  onePara.Value = “ a string ”