.Net 下对SqlServer2000中的存储过程的调用

news/2024/6/17 23:11:02
首先,在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 ”

http://www.niftyadmin.cn/n/1958829.html

相关文章

怎么提高你的人生档次

1.哈佛有一个著名的理论:人的差别来源于学习,经常抽出时间用来阅读、学习、思考,你会发现,你的人生会发生改变,成功会向你招手。 2.无论你的收入是多少,记得分成五份进行规划投资:增加对身体的投…

OnBecameVisible和OnBecameInvisible ,OnWillRenderObject

http://www.cnblogs.com/wonderKK/p/4112304.html OnBecameVisible 和 OnBecameInvisible ,OnWillRenderObject 只有在所挂物体(不包括子物体)有render才有效 //可见 private void OnBecameVisible() { _isVisible true; } //不可见 privat…

django-第一个项目

1、下载后解压 python setup.py install 2、设置path set PATHd:\python27\scripts;%path% 3、生成初步构架 F:\pro>django-admin.py startproject adcschat 4、构架内容: urls将url模式映射到你应用程序上 setting包含了项目的默认设置 manage同这个dja…

最赚钱的行业和公司排行榜(verified 版本)

【外资证券】:代表性公司:高盛、中金、摩根士丹利等单位第一年收入:50-80万左右(中金第一年基本工资25万,奖金35万,福利10万)五年后收入:300万左右工作时间量:每天18个小…

NGUI版虚拟摇杆joystick

http://blog.csdn.net/anyuanlzh/article/details/40107577 下面是我用nui实现的一个虚拟摇杆。 1,示图 2、代码如下,都有比较详细的注释,就不说明了。 [csharp] view plaincopyusing UnityEngine; using System.Collections; using Syst…

java核心技术之 ArrayList应用 【职员薪水管理系统】

职员薪水管理系统需求如下: /*** author:kevin* date:20110-7-15* function:use ArrayList to build a system of EmployeeSalaryMangement ,* the system is useful for manager to add new employeeinformation,delete employeeinformation,* update employeeinfo…

结合存储过程开发数据库应用程

存储过程提供了数据驱动应用程序中的许多优点。利用存储过程,数据库操作可以封装在单个命令中,为获取最佳性能而进行优化并通过附加的安全性得到增强;利用存储过程,还可以获得sql语句的重用,节省开发时间。在.NET中&am…

python-操作postgresql

PostgreSQL 至少有至少 3 个 Python 接口程序可以访问 PosgreSQL: psycopg, PyPgSQL 和 PyGreSQL. 第四个, PoPy, 现在已经被废弃(2003年, 它贡献出自己的代码, 与PygreSQL整合在一起). 这三个接口程序各有长处, 各有缺点, 根据实践结果选择使用哪个接口是个好主意. 多亏他们…