zoukankan
html css js c++ java
C#中使用临时存储过程
Code
string
strSql
=
""
;
SqlConnection sqlCon
=
new
SqlConnection(HeadStartConnString);
SqlCommand sqlCommStoreProcedue
=
new
SqlCommand();
sqlCommStoreProcedue.Connection
=
sqlCon;
sqlCommStoreProcedue.CommandType
=
CommandType.Text;
if
(chk.Checked)
{
strSql
=
"
Create PROCEDURE #ImgeUpdate \n @RptImage Image, \n @RptDescription varchar(1000) \n as update Reports set RptImage = @RptImage, RptDescription = @RptDescription where RptID =
"
+
rptID;
}
else
strSql
=
"
Create PROCEDURE #ImgeUpdate \n @RptDescription varchar(1000) \n as update Reports set RptDescription = @RptDescription where RptID =
"
+
rptID;
sqlCommStoreProcedue.CommandText
=
strSql;
sqlCon.Open();
sqlCommStoreProcedue.ExecuteNonQuery();
SqlCommand sqlCom
=
new
SqlCommand();
sqlCom.Connection
=
sqlCon;
sqlCom.CommandType
=
CommandType.StoredProcedure;
sqlCom.CommandText
=
"
#ImgeUpdate
"
;
if
(chk.Checked)
{
if
(filUL.HasFile)
{
int
intImgSize
=
filUL.PostedFile.ContentLength;
Stream ImgStream
=
filUL.PostedFile.InputStream;
byte
[] ImgContent
=
new
byte
[intImgSize];
int
intStatus
=
ImgStream.Read(ImgContent,
0
, intImgSize);
SqlParameter prmImg
=
new
SqlParameter(
"
@RptImage
"
, SqlDbType.Image);
prmImg.Value
=
ImgContent;
sqlCom.Parameters.Add(prmImg);
sqlCom.Parameters[
"
@RptImage
"
].Direction
=
ParameterDirection.Input;
}
}
SqlParameter prmDes
=
new
SqlParameter(
"
@RptDescription
"
, SqlDbType.VarChar,
1000
);
prmDes.Value
=
txtDesp.Text.ToString().Trim();
sqlCom.Parameters.Add(prmDes);
sqlCom.Parameters[
"
@RptDescription
"
].Direction
=
ParameterDirection.Input;
try
{
sqlCom.ExecuteNonQuery();
ClientScript.RegisterStartupScript(
this
.GetType(),
"
closeWin_Save
"
,
"
<script>alert('Save This Record Succeed!');window.close();</script>
"
);
}
catch
(SqlException sqlE)
{
ClientScript.RegisterStartupScript(
this
.GetType(),
"
Error_Msg
"
,
"
<script>alert('Save This Record Failing:
"
+
sqlE.Message
+
"
');</script>
"
);
}
finally
{
sqlCommStoreProcedue.Dispose();
sqlCom.Dispose();
sqlCon.Close();
}
存储过程的效率是比较高的。
继续追寻。。。。。。
查看全文
相关阅读:
作用域 + this指向 的一道没面试题
找出数组中最大的值
统计数组中每个值出现的次数, 统计对象中每个字符出现的次数
uniapp在h5 和 APP 端兼容性 bug 解决方案
数组去重的常用方法,利用Promise实现函数按序执行
momentjs实现距离当前时长并且回现中文效果
SQL server 上机练习题
JS 9
JS 8
JS 7
原文地址:https://www.cnblogs.com/lfzwenzhu/p/1357392.html
最新文章
微信带场景参数的二维码生成与使用
PHP提取中英文首字母的方法(首字母索引)
PHP开发api接口安全验证
CI 框架 伪静态设置 去掉index.php
websocket 函数
php redis 操作手册
WEB前后端分离开发中的验证与安全问题
springboot的java打印票据
Python导出SqlServerl数据字典为excel
ie加载js的网页问题
热门文章
nodejs启动服务
centOs7安装rabbitmq3.8和erlang22
Python导出postgresql的数据字典为excel
局域网下mysql主从配置
centOS7安装mariadb数据库
本地连接服务器的redis,jedisCluster创建问题
redis的使用
先记录一下。。。。。 vue封装自己的插件
公鸡一个五块钱,母鸡一个三块钱,小鸡三个一块钱,现在要用一百块钱买一百只鸡,问公鸡,母鸡,小鸡个多少只?
uniapp 设置跨域代理
Copyright © 2011-2022 走看看