本文介绍了输入数组长于此表中的列数。在C#.NET windows应用程序中。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 您好, 我想用初始值--Select--绑定我的所有billno但是使用c#.net windows获取初始值时出错应用程序。 错误: - 输入数组长于此表中的列数。 请帮帮我。 先谢谢。 Ankit Agarwal 软件工程师 我尝试过: public DataTable GetAllBillNo() { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand(spGetAllBillNo,GetConnection()); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); DataRow dr; dr = dt.NewRow(); dr.ItemArray = new object [] {0,--Select - }; //错误在这一行。 dt.Rows.InsertAt(dr,0); 返回dt; } public void GetAllBillNo() { cmbBillNo.ValueMember =OrderID; cmbBillNo.DisplayMember =OrderID; cmbBillNo.DataSource = connClass.GetAllBillNo(); } 解决方案 Hello,I want to bind my all billno with initial value "--Select--" but its getting error with initial value using c# .net windows application."Error:- Input array is longer than the number of columns in this table.Ho can we resolve this issue.Please help me.Thanks in Advance.Ankit AgarwalSoftware EngineerWhat I have tried:public DataTable GetAllBillNo() { DataTable dt = new DataTable(); SqlCommand cmd = new SqlCommand("spGetAllBillNo", GetConnection()); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); DataRow dr; dr = dt.NewRow(); dr.ItemArray = new object[] { 0, "--Select--" };//Error in this line. dt.Rows.InsertAt(dr, 0); return dt; } public void GetAllBillNo() { cmbBillNo.ValueMember = "OrderID"; cmbBillNo.DisplayMember = "OrderID"; cmbBillNo.DataSource = connClass.GetAllBillNo(); } 解决方案 这篇关于输入数组长于此表中的列数。在C#.NET windows应用程序中。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-03 00:45