可行,不过你的方法必须是没状态的,
SQLHelper就是。
SQLHelper就是。
解决方案 »
- 重分求助,如何用.net调用打开本地摄相头
- 如果您在google文本框输入东西,他会出现只能提示,现在我想问一下,我们可不可以把他的这个智能提示取下来,比如加入到我们自己的网页下面,那岂不爽歪歪了,能么?
- BS和CS混合模式的开发求助???? [.
- 从页面A在同一个窗口打开页面B,然后再回到A。再从A打开B页面的时候
- 好奇怪的一个问题哦?很长时间都没搞定
- 菜鸟问题:更新不了
- 请高手指点?我的数据库连接字符串在Webconfig中加密后,但运行一个要用连接串的页面请求之后出现错误,,,
- 如何在webform中点击一个按钮调用windows form页面?
- 如何将一个string的编码转换成utf8编码?
- 在项目的web.config文件中设置了默认访问页,发布到iis,再通过ip访问的时候是一片空白呢?
- oracle中取分段数据出错
- help!
public class static DataAccess{
public static ConnString = "数据库连接字符串";
public static SelectData(){查询语句};
public static InsertData(){插入语句};
public static DeleteData(){删除语句};
public static UpdateData(){更新语句};
}
{
//pass through the call providing null for the set of SqlParameters
return ExecuteNonQuery(connectionString, commandType, commandText, (SqlParameter[])null);
} public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
//create & open a SqlConnection, and dispose of it after we are done.
using (SqlConnection cn = new SqlConnection(connectionString))
{
cn.Open(); //call the overload that takes a connection in place of the connection string
return ExecuteNonQuery(cn, commandType, commandText, commandParameters);
}
}
public static int ExecuteNonQuery(string connectionString, string spName, params object[] parameterValues)
{
//if we receive parameter values, we need to figure out where they go
if ((parameterValues != null) && (parameterValues.Length > 0))
{
//pull the parameters for this stored procedure from the parameter cache (or discover them & populate the cache)
SqlParameter[] commandParameters = SqlHelperParameterCache.GetSpParameterSet(connectionString, spName); //assign the provided values to these parameters based on parameter order
AssignParameterValues(commandParameters, parameterValues); //call the overload that takes an array of SqlParameters
return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName, commandParameters);
}
//otherwise we can just call the SP without params
else
{
return ExecuteNonQuery(connectionString, CommandType.StoredProcedure, spName);
}
}