日期:2014-05-18 浏览次数:21000 次
public DataTable Query(string sqlstring) { try { mobjConn = new SqlConnection(mstrConn); mobjCmd = mobjConn.CreateCommand(); mobjCmd.CommandText = sqlstring; DataTable dt_return = new DataTable(); mobjConn.Open(); SqlDataReader reader = mobjCmd.ExecuteReader(); dt_return.Load(reader); return dt_return; } catch (SqlException e) { throw e; } finally { mobjConn.Close(); } }
public DataTable Query(string sqlstring) { try { DataTable dt_return = new DataTable(); mobjAdapter = new SqlDataAdapter(sqlstring, mstrConn); mobjAdapter.Fill(dt_return); return dt_return; } catch (SqlException e) { throw e; } }