在Asp中使用存储过程数值类型值

来源:互联网 发布:nx软件下载 编辑:程序博客网 时间:2024/06/08 05:40
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

Asp中使用存储过程

  为了提高Asp程序的效率,有时需要在Asp中使用使用SqlServer的存储技术,下面简单作一个介绍。

存储过程的建立

  这里只简单介绍如何在SqlServer的企业管理器中如何建立存储过程:

(1)打开企业管理器Enterprisemanager

(2)选择服务器组(Group)、服务器、(Database)以及相就的数据库,鼠标右击对应数据库下的StoredProcdures项,在弹出的菜单中选择NewStoredProcedure,在StoredProceduresProperties中输入建立存储过程的语句。下面是一个例子:


  CREATEPROCEDUREproctest@mycolaChar(10),@mycolbChar(10),@mycolctext  AS

  Insertintochatdata(mycola,mycolb,mycolc)values(@mycola,@mycolb,@mycolc)

在SqlServer的文档中它的语法为:

  CREATEPROC[EDURE]procedure_name[;number]  [

  {@parameterdata_type}[VARYING][=default][OUTPUT]  ]

  [,...n]  [WITH  {  RECOMPILE  |ENCRYPTION

  |RECOMPILE,ENCRYPTION  }  ]  [FORREPLICATION]  AS

  sql_statement[...n]

  如果你对Sql语法不熟悉,可以使用CheckSyntax来检查语法。在上例中,表示建立存储过程名为mycola,带3个参数的存储过过程,其中第一个参数mycola数据类型为char,宽度10;第2个参数数据类型为char,宽度为10,第3个参数数据类型为text,在这里使用的是SqlServer的数据类型。

  存储过程建立后,下面就是如何在Asp程序中调用该存储过程:在Asp中调用存储过程为了提高Asp程序的效率,有时需要在Asp中使用使用SqlServer的存储技术,下面简单作一个,在上面的增加参数的语句p.Appendcm.CreateParameter("@mycolc",201,1,250)中,格式为:

p.Appendcm.CreateParameter("参数名称",类型,方向,大小)

参许参数值的类型的意义如下:

名称值整数值功能


  adDBTimeStamp135日期时间数据类型

  adDecimal14十进制整数值

  adDouble5双精度小数值

  adError10系统错误信息

AdGUID72全域性唯一识别字(Globallyuniqueidentifier)

adDispath9COM/OLE自动对象(AutomationObject)

adInteger34字节有符号整数

adIUnknown13COM/OLE对象

adLongVarBinary205大型2字节值

adLongVarChar201大型字符串值

adLongVarWChar203大型未编码字符串

adNumeric131十进制整数值

adSingle4单精度浮点小数

adSmallInt22字节有符号整数

adTinyInt161字节有符号整数

adUnsignedBigInt218字节无符号整数

adUnsignedInt194字节无符号整数

adUnsignedSmallInt182字节无符号整数

adUnsignedTinyInt171字节无符号整数

adUserDefined132用户自定义数据类型

adVariant12OLE对象

adVarBinary204双字节字符变量值

adVarChar200字符变量值

advarchar202未编码字符串变量值

adWchar130未编码字符串


方向值的意义如下:


名称值整数值功能


adParamInput1允许数据输入至该参数当中

adParamOutput2允许数据输出至该参数当中

adParamInputOutput3允许数据输入、输出至该参数当中

adparamReturnValue4允许从一子程序中返回数据至该参数当中

更多详细资源请参考SqlServer的文档和IIS的文档资源。

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击