ASP.NET错误:输入数组长度大于此表中的列数。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.ArgumentException: 输入数组长度大于此表中的列数。
错误代码如下:
DataTable sourceTable = null;
sourceTable = GetTest(tableName);
if (sourceTable == null)
{
return;
}
DataRow[] rows = sourceTable.Select("主键<>''");
DataTable retTable = new DataTable();
retTable.Rows.Add(rows);
,原因在于DataTable retTable = new DataTable();此时retTable已经生成,但是,此时并未给此表添加列,因此retTable表里的列数为0,在你dt.Rows.Add(rows);时就会异常。
解决的方法是:在DataTable retTable = new DataTable();之后使用retTable.Columns.add("列名");给retTable表对象加上列.然后再添加行。
相关文档:
using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;namespace md5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(UserMd5("8"));
Console.WriteLine(GetMd5Str("8"));
}
/**//// <summary>
/// MD5 16位加密
......
ASP.NET弹出对话框几种基本方法
ASP.NET弹出对话框几种基本方法
我们在.NET程序的开发过程中,常常需要和用户进行信息交互,比如执行某项操作是否成功,“确定”还是“取消”,以及选择“确定”或“取消”后是否需要跳转到某个页面等,下面是 ......
Beyond File | New Company: from Cheesy Sample to Social Platform Scott Hanselman in Lagoon L on Monday at 11:30 AM The web has changed and there's a new way of thinking about your applications. You can't just write some HTML and CSS anymore and expect to be the next Twitter. Hear h ......
在
vs2008为asp.net ajax添加js智能感知
今天找了好久,终于搞清楚了,scriptManager控件支持js智能感知,而从其继承的toolkitScriptManager不支持。至少在
vs2008b2中是这样。
要在js文件中添加asp.net ajax的js智能感知(与scriptManager控件无关),在js文件的开头添加这样一行即可:
//
/<referen ......
Online active users counter in ASP.NET
With this tool which is written for ASP.NET, it is possible to count the number of online users, members and guest users in web sites.
Installation
The tool installation is very simple and only takes a few minutes.
Step one - Add Reference:
After downlo ......