///
/没粗和// 封装查询表方法
///
/// 表名
/// 查凳告询条件
/枯盯// 数据库连接字符串
/// 错误信息
///
public static DataSet QueryTableInfo(string tablename, string fiter, string conStr, ref string emsg)
{
string SqlStr = string.Empty;
DataSet ds = new DataSet();
try
{
SqlConnection conn = new SqlConnection(conStr);
if (tablename != null && tablename != string.Empty)
SqlStr = "Select * from " + tablename;
if (fiter != null && fiter != string.Empty)
SqlStr += fiter;
SqlCommand sqlCommd = new SqlCommand(SqlStr, conn);
SqlDataAdapter sqlApter = new SqlDataAdapter(sqlCommd);
sqlApter.Fill(ds);
return ds;
}
catch (Exception ex)
{
emsg = ex.Message;
return null;
}
}
public DataTable GetData(String Sql,SqlConnection)
{
using(SqlDataAdapter sda = new SqlDataAdapter(str.tostring(), strconn))
{
DataSet ds = new DataSet();
sda.Fill(ds);
return ds.Tables[0];
}
return null;
}
封装SQL读取方法,传递SQL语句
可以使用WCF服务 !这个问题很好解决
123