您现在的位置是:网站首页> 编程资料编程资料
asp.net中IDataParameter调用存储过程的实现方法_实用技巧_
2023-05-24
252人已围观
简介 asp.net中IDataParameter调用存储过程的实现方法_实用技巧_
本文实例讲述了asp.net中IDataParameter调用存储过程的实现方法,是asp.net数据库程序设计中非常实用的技巧。分享给大家供大家参考。
具体实现方法如下:
public string GenerateExamePaper(string paperType, string driverID, string MacAddr) { int i; IDataParameter[] iData = new SqlParameter[4]; iData[0] = new SqlParameter("@paperType", paperType); iData[1] = new SqlParameter("@driverID", driverID); iData[2] = new SqlParameter("@MacAddr", MacAddr); iData[3] = new SqlParameter("@sReturn", SqlDbType.Char, 50, ParameterDirection.Output, false, 0, 0, string.Empty, DataRowVersion.Default,null); string aaa = ""; i= DbHelperSQL.RunProcedureParOut("Pro_GenerateExamePaper", iData, out aaa).ToString(); return aaa; } /// /// 执行存储过程,返回影响的行数 /// /// 存储过程名 /// 存储过程参数 /// 影响的行数 /// 返回output值 /// public static int RunProcedure(string storedProcName, IDataParameter[] parameters, out int rowsAffected,out str) { using (SqlConnection connection = new SqlConnection(connectionString)) { int result; connection.Open(); SqlCommand command = BuildIntCommand(connection, storedProcName, parameters); rowsAffected = command.ExecuteNonQuery(); result = (int)command.Parameters["ReturnValue"].Value; str= (int)command.Parameters["@sReturn"].Value; return result; } } 相信本文所述对大家的asp.net程序设计有一定的借鉴价值。
您可能感兴趣的文章:
相关内容
- asp.net网站防恶意刷新的Cookies与Session解决方法_实用技巧_
- 在asp.net中使用加密数据库联接字符串保证数据安全_实用技巧_
- ASP.Net中数据展示控件的嵌套使用示例_实用技巧_
- asp.net中控制反转的理解(文字+代码)_实用技巧_
- Asp.net导出Excel/Csv文本格式数据的方法_实用技巧_
- ASP.NET实现单点登陆(SSO)适用于多种情况_实用技巧_
- asp.net后台如何动态添加JS文件和css文件的引用_实用技巧_
- asp.net(C#)禁止缓存文件不让文件缓存到客户端_实用技巧_
- 使用SNK密钥文件保护你的DLL和代码不被反编译教程_实用技巧_
- ASP.NET实现伪静态网页方法小结_实用技巧_
