开发者

Loading a stored datatable into a datagridview

开发者 https://www.devze.com 2023-04-04 13:22 出处:网络
If an SQL connection is already created, and a data table is created that takes input from an excel sheet, how do I use the SP in order to load the data table into the datagridview on my desktop appl开

If an SQL connection is already created, and a data table is created that takes input from an excel sheet, how do I use the SP in order to load the data table into the datagridview on my desktop appl开发者_如何学Goication (Visual Studio 2008, Sql Server 2005 are being used)?


try this :

DataTable t = new DataTable();//in your case it's filled already like below or any other method

c.Open();
using (SqlCeDataAdapter a = new SqlCeDataAdapter("SELECT CO_COMP_ID as Company_Id,CO_COMP_NAME as Company_Name, CO_ACTIVE as Active_Status, CO_FILE_TYPE as Using_File_Type, CO_DESC as Description  FROM CompRegister", c))
{
     a.Fill(t);
     //dgvCompDet.DataSource = t;
     fnDeselectRow();
  }
 c.Close();

Give data table as data source to datagrid

dgvCompDet.DataSource = t;
0

精彩评论

暂无评论...
验证码 换一张
取 消