; {
string connectionString = System.Configuration.ConfigurationSettings.AppSettings["connectionString"];
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
//www.51aspx.com
try
{
SqlCommand cmd = new SqlCommand();
cmd = connection.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = query;
return cmd.ExecuteScalar();
}
finally
{
if ( connection.State == ConnectionState.Open )
connection.Close();
}
}
}
}
把常用的sql方法写成一个类,看起来非常清晰,功能简单。大家常用的的SqlHelper类既有过程又有sql语句实现的方法,让新手一看就晕(我现在偶尔晕晕)~~
通用函数类(字符串处理等)
namespace IndiaStudyChannel.Utils
{
/**//// <summary>
/// Summary description for Utils.
/// </summary>
/// 由 liudao 翻译整理
/// 该源码自www.51aspx.com(51aspx.com)
public class Utils
{
public Utils()
{
}
/**//// <summary>
///&nbs