ExecuteNonQuery
Executes a command that does not return rows. ExecuteDataset
Executes a command that returns rows as a DataSet. ExecuteReader
Executes a command that returns rows as a SqlDataReader. ExecuteScalar
Executes a command that returns a single value as an object. 要这四个的使用方法,带参数的,我现在还搞不懂Command type这个参数怎么填如果有使用教程,那是最好,网上的普遍都没有ExecuteNonQuery的调用,以及详细的实例.
Executes a command that does not return rows. ExecuteDataset
Executes a command that returns rows as a DataSet. ExecuteReader
Executes a command that returns rows as a SqlDataReader. ExecuteScalar
Executes a command that returns a single value as an object. 要这四个的使用方法,带参数的,我现在还搞不懂Command type这个参数怎么填如果有使用教程,那是最好,网上的普遍都没有ExecuteNonQuery的调用,以及详细的实例.
解决方案 »
- mvc
- HttpRuntime.Cache 缓存过期问题
- GRIDVIEW无刷分页问题
- @@@@@@@@@@csdn的高人们帮我一下,我有一个小问题,困扰很久!!!@@@@@@@@@@@@
- [十万火急,跟贴有分]vs2005中如何在客户端操作TreeView控件,包括节点的添加,删除等
- 怎么配置IIS上的自定义控件?
- ckfinder 设置共享路径没有权限访问问题
- 求职,大家帮我提提意见,我很乱?
- 【求助】bootstrap select 控件问题
- 请教使用KendoTreeView绑定树,只出root,无ChildNode问题
- 系统传到虚拟主机上去之后,验证控件失效怎么解决?
- datagrid格式设置,求教!
例如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 ....."
#region 删除网址分类信息函数
public int Type_Delet(int TypeID)
{
//定义SqlConnection
SqlConnection connection = null;
int bRet = -1;
try
{
try
{
connection = SysConfig.GetConnection();//在SysConfig类中获取一个数据库连接
}
catch
{
return 1;//数据库连接异常
}
// 定义输入参数parameters
SqlParameter[] arParms = new SqlParameter[2];
// 传入参数
arParms[0] = new SqlParameter("@TypeID", SqlDbType.Int); //分类ID
arParms[0].Value = TypeID;
//返回值"@RETURN_VALUE
arParms[1] = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
arParms[1].Direction = ParameterDirection.ReturnValue;
// 调用数据库访问函数
SqlHelper.ExecuteNonQuery(connection, CommandType.StoredProcedure, "sp_Type_Delete", arParms);
//bRet获取存储过程中的返回值"RETURN_VALUE
bRet = (int)arParms[1].Value; }
catch (Exception ex)
{
string errMessage = "";
for (Exception tempException = ex; tempException != null; tempException = tempException.InnerException)
{
errMessage += tempException.Message + Environment.NewLine + Environment.NewLine;
}
}
finally
{
if (connection != null)
connection.Dispose();
}
return bRet;
}
#endregion