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();
}
存储过程的效率是比较高的。
继续追寻。。。。。。
查看全文
相关阅读:
【转】Linux目录结构FHS
单链表是否有环并如何找到环入口
【转】linux dd 的简单应用
DataSet、ExecuteScalar、ExecuteReader
解决Excel只验证前8行字符串的长度
SQL Server UPSERT equivalent
用通配符替换字符串
从内存中查询表字段定义的长度大小
C#判断一个字符串是否为整数
page life cycle of master page with content page
原文地址:https://www.cnblogs.com/lfzwenzhu/p/1357392.html
最新文章
document 和 document.all 分别什么时候用
送给电脑桌前的您
智能ABC输入法超酷技巧
撬开操纵上海房价的手 楼盘供不应求原是假象
XSLT实例
成为编程高手的八大奥秘
100句温柔又体贴的话
数码相机小技巧妙用
加速磁盘碎片整理的六大技巧
真爱无言
热门文章
SQL Server 提升权限相关命令及防范
XML在Web中的简单应用
XML系列函数详解
复杂链表的复制
【转】数据库的左连接,右连接问题
最大回文子串
最大子序列和
【转】 颠倒栈
反转单词
trie树
Copyright © 2011-2022 走看看