【发布时间】:2016-04-06 19:05:27
【问题描述】:
我在将存储过程加载到 DataGridView 时遇到问题。我已经搜索了一个答案,但是我的代码看起来与我找到的每个答案都相似。存储过程在我添加的另一个 DataGridView 中运行,我将其作为固定数据源包含在内。我是 C# 的新手。谁能看出我哪里出错了?
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
SqlConnection myConn = new SqlConnection("Data Source=SERVER-SQL1;Initial Catalog=OPSystem;Integrated Security=True");
myConn.Open();
SqlCommand myCmd = new SqlCommand("spCustomers", myConn);
myCmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(myCmd);
da.Fill(dt);
dataGridView1.DataSource = da;
}
【问题讨论】:
-
this.iTManagementSystemDataSet 是什么?这里好像没有在Form的Load事件中初始化。
-
抱歉从我的代码中删除,我已经编辑了我的帖子。
标签: c# stored-procedures datagridview