Command type命今类型:一航为StoredProcedure(存储过程)和text(文本).
例如1:ds = SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, "sp_Type_AllList");
connection:数据库连接
CommandType.StoredProcedure:命令类型为存储过程.
sp_Type_AllList:存储过程名称
例如2:ds = SqlHelper.ExecuteDataset(connection, CommandType.text, "strsql");
connection:数据库连接
CommandType.text:命令类型为SQL语名.
strsql:SQL语句如"select * from table1 "或"instert into ....."
Command type命今类型:一航为StoredProcedure(存储过程)和text(文本).
例如1:ds = SqlHelper.ExecuteDataset(connection, CommandType.StoredProcedure, "sp_Type_AllList");
connection:数据库连接
CommandType.StoredProcedure:命令类型为存储过程.
sp_Type_AllList:存储过程名称
例如2:ds = SqlHelper.ExecuteDataset(connection, CommandType.text, "strsql");
connection:数据库连接
CommandType.text:命令类型为SQL语名.
strsql:SQL语句如"select * from table1 "或"instert into ....."
本文介绍了在使用SQLHelper类执行数据库操作时两种主要的命令类型:存储过程和文本命令。通过具体的示例,展示了如何利用存储过程提高代码复用性和安全性,以及如何直接执行SQL语句进行灵活的数据操作。
420

被折叠的 条评论
为什么被折叠?



