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();
}
存储过程的效率是比较高的。
继续追寻。。。。。。
查看全文
相关阅读:
读《豆瓣的基础架构》有感
读《【解密】京东B2B业务架构演变》有感
soa
读《京东咚咚架构演进》有感
读《游戏服务器的架构演进(完整版)》有感
读《京东物流系统架构演进中的最佳实践》有感
读《微博众筹的架构设计》有感
读《新浪微博如何应对极端峰值下的弹性扩容挑战》有感
读《微博推荐架构的演进》有感
读《新浪微博用户兴趣建模系统架构》有感
原文地址:https://www.cnblogs.com/lfzwenzhu/p/1357392.html
最新文章
不同编码写入文件
替换文件中字符(正则)
浅析Python编码问题
基础知识汇总
Python BeautifulSoup 简单笔记
常见测试点
ADB-常见命令使用详解
购物车怎么测试?
支付功能怎么测试
一个输入框怎么测试?
热门文章
登陆功能怎么测试?
04_Oracle_常见的命令
02_Python3基础
01_Python3安装
LoadRunner web_set_sockets_option()--常用函数
LoadRunner 手动关联
本地域名解析
Linux 安装 tree命令
02、操作文件
01、Linux介绍
Copyright © 2011-2022 走看看