1个回答
展开全部
/// <summary>
/// 数据库连接字段
/// </summary>
private static string STR_CON = @".\sql2005;database = cuiwei; integrated security =sspi";
/// <summary>
/// 根据给定命令获得信息
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static SqlDataReader GetAllMap(string sql)
{
SqlConnection con = new SqlConnection(STR_CON);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
try
{
con.Open();
SqlDataReader red = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return red;
}
catch ( Exception e )
{
con.Close();
throw new Exception(e.Message);
}
}
/// 数据库连接字段
/// </summary>
private static string STR_CON = @".\sql2005;database = cuiwei; integrated security =sspi";
/// <summary>
/// 根据给定命令获得信息
/// </summary>
/// <param name="sql"></param>
/// <returns></returns>
public static SqlDataReader GetAllMap(string sql)
{
SqlConnection con = new SqlConnection(STR_CON);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = sql;
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
try
{
con.Open();
SqlDataReader red = cmd.ExecuteReader(CommandBehavior.CloseConnection);
return red;
}
catch ( Exception e )
{
con.Close();
throw new Exception(e.Message);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询