数据表到数据网格视图 [英] DataTable to Datagridview

查看:86
本文介绍了数据表到数据网格视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个获胜表格应用程序,我的数据网格不想填写.
我的表名叫OPENINGHOURS.

我收到的错误消息是:

要获得这些营业时间,我必须在GUI的表单加载中进行哪些设置?

DAL:
++++

I have a win form application and my datagrid does not want to fill.
My tabelname is called OPENINGHOURS.

The error message I receive is:

What do I have to set in the formload of my GUI to get those openinghours?

DAL:
++++

public static DataTable GetOpeningHoursFromBranch(string branchname)
{
    try
    {

        int brid = BranchDAL.GetBranchID(branchname);

        string sql = "SELECT * FROM OPENINGHOURS WHERE BranchId=@brid";

        CommandParameterList localparams = new CommandParameterList();

        localparams.Add(new CommandParameter("@brid", brid, DbParameterTypes.Int32, ParameterDirection.Input));

        localDAC.LocalParameters = localparams;

        return localDAC.ExecuteDT(sql, AssignmentTypes.SqlStatement, "OPENINGHOURS");
    }
    catch (SQLDacException ex)
    {
        throw new BranchDALException(ex.Message);
    }
    catch (Exception ex)
    {
        throw new BranchDALException(ex.Message);
    }
}


BLL
++++


BLL
++++

public static DataTable GetOpeningHoursFromBranch(string branchname)
  {
      try
      {
          return BranchDAL.GetOpeningHoursFromBranch(branchname);
      }
      catch (BranchDALException ex)
      {
          throw new BranchBLLException(ex.Message);
      }
      catch (Exception ex)
      {
          throw new BranchBLLException(ex.Message);
      }
  }

推荐答案

已解决.

自己找到它的:-)

Solved.

Found it myself :-)

DataTable localDT = new DataTable("OpeningHours");
localDT = BranchDAL.GetOpeningHoursFromBranch(textBoxBranchName.Text);
dataGridViewOpeningHours.DataSource = localDT;
dataGridViewOpeningHours.Refresh();



[edit]添加了代码块[/edit]



[edit]code block added[/edit]


这篇关于数据表到数据网格视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆