namespace 操作数据
{
    class SqlHelper
    {
        public DataSet SqlTODs(string cmdstring)
        {
            DataSet ds = new DataSet();
            try
            {
                string sqlstring = System.Configuration.ConfigurationManager.ConnectionStrings["dbStr"].ConnectionString;
                using (SqlConnection conn = new SqlConnection(sqlstring))
                {
                    conn.Open();
                    //string cmd = cmdstring;
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = cmdstring;
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.Fill(ds);
                    return ds;
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("错误信息为:  " + ex.Message);
                return ds;
            }
          
        }
    }
}

 

 

 

 

 

 

原因是:没有给SqlDataAdapter传递参数  ,

相关文章:

  • 2022-12-23
  • 2021-12-03
  • 2021-11-28
  • 2022-12-23
  • 2021-10-19
  • 2022-12-23
  • 2021-11-25
猜你喜欢
  • 2022-12-23
  • 2021-09-17
  • 2022-01-24
  • 2022-02-25
  • 2021-07-08
  • 2018-05-23
  • 2022-12-23
相关资源
相似解决方案