| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 929 人关注过本帖
标题:数组访问越界
取消只看楼主 加入收藏
fanjinxiang
Rank: 1
等 级:新手上路
帖 子:13
专家分:7
注 册:2012-10-15
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:0 
数组访问越界
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=fjx;User ID=sa;Password=1234");
            SqlCommand com = conn.CreateCommand();
             = "select * from Department";
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = com;
            DataSet ds = new DataSet();
            conn.Open();
            da.Fill(ds);
            conn.Close();
            int i = ds.Tables[0].Rows.Count;
            if (i>0)
            {
                int iRow = ds.Tables[0].Rows.Count;
                int iColumn = 2;
                for (int j = 0; j < iRow; j++)
                {
                    TableRow newRow = new TableRow();
                    tblshow.Controls.Add(newRow);
                    for (int k = 0; k < iColumn; k++)
                    {
                        TableCell newCell = new TableCell();
                        string strContent = "";
                        if (k == 0)
                        {
                            int iIndex = j + 1;
                            strContent = iIndex.ToString();
                        }
                        else
                        {
                            strContent = ds.Tables[0].Rows[j][k].ToString();
                        }
                        newCell.Text = strContent;
                        newRow.Controls.Add(newCell);
                    }
                }
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~\\Default.aspx/");
    }
}运行后提示我数组访问越界,什么问题
搜索更多相关主题的帖子: 越界 void public 
2012-11-04 21:03
快速回复:数组访问越界
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020456 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved