ycy18908382411
不会写代码的小学僧
2017-01-13 08:43

C#问题(跪求高手指点迷津)

  • c#
  • select

如图所示,不知道问题在哪图片说明 public static DataTable GetDataTable(string sqlStr, params SqlParameter[] paras)
{
SqlCommand cmd = new SqlCommand(sqlStr, conn);
if (paras !=null && paras.Length > 0)
{
cmd.Parameters.AddRange(paras);
}
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
try
{
da.Fill(dt);
}
catch (Exception ex)
{

            throw ex;
        }
        return dt;
    }



             private void LoadBooks()
    {
        string sqlStr = "select * from Book";
        DataTable dt = SqlHelper.GetDataTable(sqlStr);
        dgvBooks.DataSource = dt;
        MessageBox.Show(dt.Rows.Count.ToString ());
    }

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换