MS Access -- Form's OnUpdate not working properly!
Ted Sheedy posted at 24-Jul-08 05:34

Hello All,

This is a MS Access question using VBA.....

I have a continuous form that is bound to a table. The form has text boxes showing values from the table. In order to prevent people from editing the table on accident by typing in the text boxes on the form, I want to make an "edit" check box on each record that when checked (=TRUE) will enable the text boxes for that record only to be edited.

Unfortunately, it is enabling all the text boxes on the form.

The check box is bound to a created field in the table with a default value of FALSE, and when I check the first record's box, it sets only that record to TRUE in the underlying table. My code (below) says that on an update, if the value of the checkbox is TRUE, that it should enable the text boxes, but if FALSE, should not enable them.

When I edit one of the text box fields it only applies to that record on the table, not all the records, so what do I need to do to get only the current record's text boxes to be enabled, and keep the others "not enabled" until their check boxes are checked???

I'm assuming this has something to do with the fact that every text box on every record of the continuous form is techincally the same text box.

I tried my hardest not to confuse... but as you all know its not easy explaining code. 

Here is the simplified code I have.... Any help is GREATLY APPRECIATED!

Private Sub Check7_AfterUpdate()
If Check7.Value = True Then

         RecEntry.Enabled = True
        RecEntry.Locked = False
    Else
        
        RecEntry.Enabled = False
        RecEntry.Locked = True
   
End If
End Sub
 



 
Joining datasets from multiple stored procedures
Lindsey Cope posted at 24-Jul-08 05:42
Bear with me, I'm very new at this.

I'm using 2 stored procedures to pull similar data for 2 datasets. I am needing to either combine the 2 stored procs to get 1 dataset (which would be pulling the data from, effectively, 4 different tables) using a join, or use the 2 stored procs to insert/update another table containing all the data. I am using this to feed a report in Visual Studio that compares the data for one subsection to the overall totals - ie. page views of one section of the website to page views overall. The 2 stored procs currently work, and return data, my issue is solely with getting the 2 datasets joined somehow.

example code - (and I apologize profusely because, as I said, I am very new at this)
 
Insert into reporting..subsections
(date,
Visitorsoverview,
visitsoverview,
viewsoverview,
durationoverview,
visitorssub,
visitssub,
viewssub,
durationsub)
select
    date_from
    ,max([b.visitors])visitors
    ,max([b.visits])visits
    ,max([b.page_views])views
    ,max(datediff(ss,0,[b.visit_duration]))duration
    ,count(distinct a.machine_id) as visitors
    ,count(#subsite1_sessions.machine_id) as visits
    ,count(a.stem) as views_
    ,avg(#travel_durations.interval) as avg_duration

from
     subsite1  a

left join
    #subsite1_sessions on #subsite1_sessions.machine_id = a.machine_id and #subsite1_sessions.date = a.date
left join
    #subsite1_durations on #travel_durations.machine_id = a.machine_id and #subsite1_durations.date = a.date  and #subsite1_durations.stem = a.stem
left join Profiles..Overview b ON a.date_only = b.date_from
   
where
     a.stem like '%/subsite1%'
    and a.date between @date_start and @date_end
    and [b.profile] = 'subsite1'
    and b.period = 'daily'
   AND b.date_from >= @date_start and b.date_from < @date_end

group by
    date_from
order by
    date_from

It, of course, doesn't work. The error is "Invalid Column Name" for the 'b.*' columns. I'm assuming that the reason this is happening is because I'm not designating the second table correctly?


 
IF function
Mike Northrop posted at 24-Jul-08 01:54
I am trying to write an IF function with a nested VLOOKUP function, only I keep getting a return of "#N/A".

The function so far:
=IF(VLOOKUP(A7,$A$68:$AA$96,25,FALSE)=#N/A,Y7,(VLOOKUP(A7,$A$68:$AA$96,25,FALSE)+Y7))

Where the highlighted "#N/A" is, I would like to know if there is a simple function or symbol that would work.

The way this is set up, the function is looking for data that isn't there. Hence, why I am getting this return. I could always do this the long, tedious, manual way, but I just don't want to.

If anyone can help, please do!


 
subscript out of range error
hema latha posted at 24-Jul-08 10:36

Hi,

 I want to copy data from a worksheet and paste in another sheet in different work book..

w.xls is my source sheet and wd is destination..

I run the macros from wd.xls

' Force explicit variable declaration
Option Explicit
 Dim LastColumn As Integer
 Dim Cell As Object
 

Sub CopySheetToSheet()
   Dim StartRow As Integer
   'dest = ActiveSheet.Name
        Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
   
    StartRow = 2
   
    For Each Cell In Range(Cells(2, 1), Cells(ActiveSheet.UsedRange.Cells.SpecialCells(xlLastCell).Row, 1))
        Call CopyCellToCell(Cell.Row, Cell.Column, StartRow, 1)
        Call CopyCellToCell(Cell.Row, Cell.Column + 1, StartRow, 3)
             Call stod(StartRow, 1, 4)
        Call stod(StartRow, 2, 6)
        StartRow = StartRow + 7
           Next
End Sub

 Function CopyRowToColumn(ByVal StartRow, ByVal RowNumber, ByVal ColumnNumber)
    Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
    LastColumn = ActiveSheet.UsedRange.Cells.SpecialCells(xlLastCell).Column
   
    For Each Cell In Range(Cells(RowNumber, 7), Cells(RowNumber, 13))
        Call CopyCellToCell(Cell.Row, Cell.Column, StartRow, ColumnNumber)
       
        StartRow = StartRow + 1
    Next

    CopyRowToColumn = StartRow
End Function
 Function stod(ByVal StartRow, ByVal RowNumber, ByVal ColumnNumber)
    Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
    LastColumn = ActiveSheet.UsedRange.Cells.SpecialCells(xlLastCell).Column
 
    For Each Cell In Range(Cells(RowNumber, 7), Cells(RowNumber, 13))
        Call CopyCellToCell(Cell.Row, Cell.Column, StartRow, ColumnNumber)
       
        StartRow = StartRow + 1
    Next

    stod = StartRow
End Function

Sub CopyCellToCell(ByVal FromRow, ByVal FromColumn, ByVal ToRow, ByVal ToColumn)
    Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
    Cells(FromRow, FromColumn).Select
    Selection.Copy
   
    Application.Goto Workbooks("wd.xls").Sheets("Sheet1").Select
      Cells(ToRow, ToColumn).Select
    ActiveSheet.Paste
End Sub

 

 

I get subscript out of error in the highlighted line

Could anybody help in this..

Thanx in advance.....



 
subscript out of range error
hema latha posted at 24-Jul-08 10:32

Hi,

 I want to copy data from a worksheet and paste in another sheet in different work book..

w.xls is my source sheet and wd is destination..

I run the macros from wd.xls

' Force explicit variable declaration
Option Explicit
 Dim LastColumn As Integer
 Dim Cell As Object
 

Sub CopySheetToSheet()
   Dim StartRow As Integer
   'dest = ActiveSheet.Name
        Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
   
    StartRow = 2
   
    For Each Cell In Range(Cells(2, 1), Cells(ActiveSheet.UsedRange.Cells.SpecialCells(xlLastCell).Row, 1))
        Call CopyCellToCell(Cell.Row, Cell.Column, StartRow, 1)
        Call CopyCellToCell(Cell.Row, Cell.Column + 1, StartRow, 3)
             Call stod(StartRow, 1, 4)
        Call stod(StartRow, 2, 6)
        StartRow = StartRow + 7
           Next
End Sub

 Function CopyRowToColumn(ByVal StartRow, ByVal RowNumber, ByVal ColumnNumber)
    Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
    LastColumn = ActiveSheet.UsedRange.Cells.SpecialCells(xlLastCell).Column
   
    For Each Cell In Range(Cells(RowNumber, 7), Cells(RowNumber, 13))
        Call CopyCellToCell(Cell.Row, Cell.Column, StartRow, ColumnNumber)
       
        StartRow = StartRow + 1
    Next

    CopyRowToColumn = StartRow
End Function
 Function stod(ByVal StartRow, ByVal RowNumber, ByVal ColumnNumber)
    Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
    LastColumn = ActiveSheet.UsedRange.Cells.SpecialCells(xlLastCell).Column
 
    For Each Cell In Range(Cells(RowNumber, 7), Cells(RowNumber, 13))
        Call CopyCellToCell(Cell.Row, Cell.Column, StartRow, ColumnNumber)
       
        StartRow = StartRow + 1
    Next

    stod = StartRow
End Function

Sub CopyCellToCell(ByVal FromRow, ByVal FromColumn, ByVal ToRow, ByVal ToColumn)
    Application.Goto Workbooks("w.xls").Sheets("Sheet1").Select
    Cells(FromRow, FromColumn).Select
    Selection.Copy
   
    Application.Goto Workbooks("wd.xls").Sheets("Sheet1").Select
      Cells(ToRow, ToColumn).Select
    ActiveSheet.Paste
End Sub

 

 

Could anybody help in this..

Thanx in advance.....



 
Retrieve data from MS SQL Server 2000, fill a DataSet and populate to a DataGridView (C# 2008)
Aldo Liaks posted at 24-Jul-08 09:31

Hi guys,

 

Note:  I am working under "MS SQL Server 2000 "and "C# in Visual Studio 2008".

I need to retrieve data from MS SQL Server 2000 and populate to a DataGridView (C# 2008).

The query used to retrieve data from SQL Server looks like:

USE SCHE

if object_id('AuxTable20080722123030') is not null exec('DROP TABLE ' + 'AuxTable20080722123030')

 

SELECT DISTINCT

Accounts.AccountKey AS 'Accounts.AccountKey',

Accounts.FullName AS 'Accounts.FullName',

Accounts.Filter AS 'Accounts.Filter',

Accounts.SortGroup AS 'Accounts.SortGroup'

INTO AuxTable20080722123030

FROM

ACCOUNTS AS Accounts

WHERE

Accounts.SORTGROUP Between '0' AND '379'

AND Accounts.SORTGROUP Not Between '100' AND '150';

GO

 

ALTER TABLE AuxTable20080722123030

ADD

[TotalCosts] real;

GO

 

UPDATE AuxTable20080722123030

SET

[TotalCosts] = 10

 

SELECT DISTINCT

[Accounts.AccountKey],

[TotalCosts]

FROM AuxTable20080722123030

 

I need to run the query below using C# code.

I found no way to run it from code as a single batch, so after dealing with it (based on post's suggestions), I worked out two different possibilities.

I hope this will be useful for other people.

The first one is Creating and Running a Stored Procedure.

The second one is Running the query batch by batch (multi – batch).

 

Thanks for the help!

Aldo.

 

Creating and Running a Stored Procedure:

// Form Constructor

public Report()

{

InitializeComponent();

CreateSP();

RunSP();

}

 

// Method

#region Methods to Create and run Stored Procedures

private void CreateAndRunSP()

{

string conn = @"server=x;uid=y;pwd=z;database=xyz";

 

createSP_Aldo01 = String.Format(createSP_Aldo01, "AuxTable20080722123030");

 

try

{

using (SqlConnection myConnection = new SqlConnection(conn))

{

using (SqlCommand sqlComm = new SqlCommand())

{

myConnection.Open();

sqlComm.Connection = myConnection;

sqlComm.CommandText = "USE SCHE";

sqlComm.ExecuteNonQuery();

sqlComm.CommandText = "IF object_id('Aldo01') is not null drop procedure Aldo01 ";

sqlComm.ExecuteNonQuery();

sqlComm.CommandText = createSP_Aldo01;

sqlComm.ExecuteNonQuery();

sqlComm.CommandText = "EXEC Aldo01 '0', '379', '100', '150' ";

using (SqlDataAdapter da = new SqlDataAdapter(sqlComm))

{

DataSet ds = new DataSet();

da.Fill(ds, "Report");

dgvReport.DataSource = ds.Tables[0];

myConnection.Close();

}

}

}

}

catch (Exception ex)

{

MessageBox.Show("Error: " + ex.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);

Application.Exit(); // finish the program

}

}

 

// Method

private void CreateSP()

{

string conn = @"server=x;uid=y;pwd=z;database=xyz";

createSP_Aldo01 = String.Format(createSP_Aldo01, "AuxTable20080722123030");

try

{

using (SqlConnection myConnection = new SqlConnection(conn))

{

using (SqlCommand sqlComm = new SqlCommand())

{

myConnection.Open();

sqlComm.Connection = myConnection;

sqlComm.CommandText = "USE SCHE";

sqlComm.ExecuteNonQuery();

sqlComm.CommandText = "IF object_id('Aldo01') is not null drop procedure Aldo01 ";

sqlComm.ExecuteNonQuery();

sqlComm.CommandText = createSP_Aldo01;

sqlComm.ExecuteNonQuery();

}

}

}

catch (Exception ex)

{

MessageBox.Show("Error: " + ex.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);

Application.Exit(); // finish the program

}

}

 

private void RunSP()

{

string conn = @"server=x;uid=y;pwd=z;database=xyz";

try

{

using (SqlConnection myConnection = new SqlConnection(conn))

{

using (SqlCommand sqlComm = new SqlCommand())

{

myConnection.Open();

sqlComm.Connection = myConnection;

sqlComm.CommandText = "USE SCHE";

sqlComm.ExecuteNonQuery();

sqlComm.CommandText = "EXEC Aldo01 '0', '379', '100', '150' ";

using (SqlDataAdapter da = new SqlDataAdapter(sqlComm))

{

DataSet ds = new DataSet();

da.Fill(ds, "Report");

dgvReport.DataSource = ds.Tables[0];

myConnection.Close();

}

}

}

}

catch (Exception ex)

{

MessageBox.Show("Error: " + ex.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);

Application.Exit(); // finish the program

}

}

#endregion

 

// SQL String declaration.

#region Create Stored Procedure in MS SQL Server

string createSP_Aldo01 = ""

+ @" CREATE PROCEDURE Aldo01 "

+ @" @AccSGBtw_Start varchar(25), "

+ @" @AccSGBtw_End varchar(25), "

+ @" @AccSGNotBtw_Start varchar(25), "

+ @" @AccSGNotBtw_End varchar(25) "

+ @" AS "

+ @" if object_id('{0}') is not null exec('DROP TABLE ' + '{0}') "

+ @" SELECT DISTINCT "

+ @" Accounts.AccountKey AS 'Accounts.AccountKey', "

+ @" Accounts.FullName AS 'Accounts.FullName', "

+ @" Accounts.Filter AS 'Accounts.Filter', "

+ @" Accounts.SortGroup AS 'Accounts.SortGroup' "

+ @" INTO {0} "

+ @" FROM "

+ @" ACCOUNTS AS Accounts "

+ @" WHERE "

+ @" Accounts.SORTGROUP Between @AccSGBtw_Start AND @AccSGBtw_End "

+ @" AND Accounts.SORTGROUP Not Between @AccSGNotBtw_Start AND @AccSGNotBtw_End "

+ @" exec ('ALTER TABLE ' + '{0}' + ' ADD [TotalCosts] real ;') "

+ @" exec ('UPDATE ' + '{0}' + ' SET [TotalCosts] = 10;') "

+ @" exec ('SELECT DISTINCT [Accounts.AccountKey], [TotalCosts] FROM  ' + '{0}' + ' ;') "

+ @"";

#endregion

 

Running the query batch by batch (multi – batch):

// Form Constructor

public Report()

{

InitializeComponent();

RunningQueryBatchByBatch();

}

 

// Method

private void RunningQueryBatchByBatch()

{

string conn = @"server=x;uid=y;pwd=z;database=xyz";

cmmdString02 = String.Format(cmmdString02, "AuxTable20080722123030");

cmmdString03 = String.Format(cmmdString03, "AuxTable20080722123030");

cmmdString04 = String.Format(cmmdString04, "AuxTable20080722123030");

cmmdString05 = String.Format(cmmdString05, "AuxTable20080722123030");

cmmdString06 = String.Format(cmmdString06, "AuxTable20080722123030");

try

{

using (SqlConnection myConnection = new SqlConnection(conn))

{

using (SqlCommand sqlComm = new SqlCommand())

{

myConnection.Open();

sqlComm.Connection = myConnection;

sqlComm.CommandText = cmmdString01; sqlComm.ExecuteNonQuery();

sqlComm.CommandText = cmmdString02; sqlComm.ExecuteNonQuery();

sqlComm.CommandText = cmmdString03; sqlComm.ExecuteNonQuery();

sqlComm.CommandText = cmmdString04; sqlComm.ExecuteNonQuery();

sqlComm.CommandText = cmmdString05; sqlComm.ExecuteNonQuery();

sqlComm.CommandText = cmmdString06; sqlComm.ExecuteNonQuery();

using (SqlDataAdapter da = new SqlDataAdapter(sqlComm))

{

DataSet ds = new DataSet();

da.Fill(ds, "Report");

dgvReport.DataSource = ds.Tables[0];

}

sqlComm.CommandText = cmmdString02; sqlComm.ExecuteNonQuery();

myConnection.Close();

}

}

}

catch (Exception ex)

{

MessageBox.Show("Error: " + ex.Message, "Connection error", MessageBoxButtons.OK, MessageBoxIcon.Error);

Application.Exit(); // finish the program

}

}

 

// SQL String declaration.

#region Running query batch by batch.

string cmmdString01 = " USE SCHE ";

string cmmdString02 = " if object_id('{0}') is not null exec('DROP TABLE ' + '{0}') ";

string cmmdString03 = ""

+ @" SELECT DISTINCT "

+ @" Accounts.AccountKey AS 'Accounts.AccountKey', "

+ @" Accounts.FullName AS 'Accounts.FullName', "

+ @" Accounts.Filter AS 'Accounts.Filter', "

+ @" Accounts.SortGroup AS 'Accounts.SortGroup' "

+ @" INTO {0} "

+ @" FROM "

+ @" ACCOUNTS AS Accounts "

+ @" WHERE "

+ @" Accounts.SORTGROUP Between '0' AND '379' "

+ @" AND Accounts.SORTGROUP Not Between '100' AND '150' "

+ @" ; ";

string cmmdString04 = ""

+ @" ALTER TABLE {0} "

+ @" ADD "

+ @" [TotalCosts] real "

+ @" ; ";

string cmmdString05 = ""

+ @" UPDATE {0} "

+ @" SET "

+ @" [TotalCosts] = 10 ";

string cmmdString06 = ""

+ @" SELECT DISTINCT "

+ @" [Accounts.AccountKey], "

+ @" [TotalCosts] "

+ @" FROM {0} "

+ "";

#endregion



 
Gridview exception error -pls help
abi ton posted at 24-Jul-08 09:25


HI guys,

this is my code,what i am trying to do is,read to different csv files, create datatables dt,dt1 and put them on 1 gridview.when i read only 1 file and create only 1 table it works fine but wen i try ti read both,i run into this error, this is my code

System.IndexOutOfRangeException: Cannot find column 0. at System.Data.DataColumnCollection.get_Item(Int32 index) at System.Data.DataRow.set_Item(Int32 columnIndex, Object value) at ASP.default_aspx.BindGrid() in h:\My Documents\Visual Studio 2008\WebSites\WebSite8\Default.aspx:line 199 at ASP.default_aspx.Page_Load(Object sender, EventArgs e) in h:\My Documents\Visual Studio 2008\WebSites\WebSite8\Default.aspx:line 27

I think the problem is the coulmns are not getting added the second time,

 ANY SUGGESTIONS??

<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Import namespace="System.Collections.Generic" %>

<%@ Import namespace="System.IO" %>

<%@ Import namespace="System.Data" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server" language="C#">

private int ENV_CD_COL_INDEX = -1;

private int SITE_COL_INDEX = -1;

private int FILER_NM_COL_INDEX = -1;private int SHARE_TYPE_COL_INDEX = -1;

 

 

protected void Page_Load(object sender, EventArgs e)

{

 

DateTime dtNow = DateTime.Now;

StringBuilder sb = new StringBuilder();

sb.Append("Today's Date is : " + dtNow.ToLongDateString() + "<br><br>");

lbDatetime.Text = sb.ToString();

try

{

BindGrid();///////////////////////////////////////////////////////////////////////////////line 27

}

catch (Exception ex)

{

Response.Write(ex.ToString());

}

}

protected void gvForPaging_PageIndexChanging(object sender, GridViewPageEventArgs e)

{

try

{

gvResults.PageIndex = e.NewPageIndex;

BindGrid();

}

catch (Exception ex)

{

Response.Write(ex.ToString());

}

}

protected void btnShow_Click(object sender, EventArgs e)

{

try

{

gvResults.AllowPaging =
true;

BindGrid();

}

catch (Exception ex)

{

Response.Write(ex.ToString());

}

}

protected void btnShow1_Click(object sender, EventArgs e)

{

try

{

gvResults.AllowPaging =
false;

BindGrid();

}

catch (Exception ex)

{

Response.Write(ex.ToString());

}

}

private void BindGrid()

{

int lineCount = 0;string line = "";

 

 

List<string> environment = new List<string>();

List<string> site = new List<string>();

List<string> filer = new List<string>();

List<string> shareType = new List<string>();

///////////////////////////////////////////////////////////////////////////// READING 1st FILE 

 

FileStream fs = new FileStream(@"C:\univ\nas_allocation1.csv", FileMode.Open, FileAccess.Read);

StreamReader sr = new StreamReader(fs);

//string fileContent = sr.ReadToEnd();

//Response.Write(fileContent);

//sr.Close();

//fs.Close();

DataTable dt = new DataTable();while (sr.Peek() > -1)

{

line = sr.ReadLine();

if (line.Trim() == string.Empty) continue;if (lineCount++ == 0)

{

string[] cols = line.Split(new string[] { "," }, StringSplitOptions.None);

for (int i = 0; i < cols.Length; i++)

{

//if (cols[i] == "ENV_CD") ENV_CD_COL_INDEX = i;

//if (cols[i] == "SITE") SITE_COL_INDEX = i;

//if (cols[i] == "FILER_NM") FILER_NM_COL_INDEX = i;

//if (cols[i] == "SHARE_TYPE") SHARE_TYPE_COL_INDEX = i;

DataColumn dc = new DataColumn(cols[i]);

dt.Columns.Add(dc);

}

}

else

{

string[] values = line.Split(new string[] { "," }, StringSplitOptions.None);

bool valid = true;

if (drpEnvironment.Text != "All" && line.IndexOf(drpEnvironment.Text + ",") < 0) valid &= false;

if (drpSite.Text != "All" && line.IndexOf(drpSite.Text + ",") < 0) valid &= false;

if (drpFiler.Text != "All" && line.IndexOf(drpFiler.Text + ",") < 0) valid &= false;

if (drpShareType.Text != "All" && line.IndexOf(drpShareType.Text + ",") < 0) valid &= false;

 

if (valid)

{

DataRow dr = dt.NewRow();for (int i = 0; i < values.Length; i++)

{

dr[i] = values[i];

}

dt.Rows.Add(dr);

}

gvResults.Columns[5].Visible = false;

gvResults.Columns[6].Visible = false;

gvResults.Columns[10].Visible = false;

//gvResults.Columns[11].Visible = false;

}

}

sr.Close();

 

/////////////////////////////////////////////////////////////////READING file2

FileStream fs1 = new FileStream(@"C:\univ\nas_allocation1.csv", FileMode.Open, FileAccess.Read);

StreamReader sr1 = new StreamReader(fs1);

//string fileContent = sr.ReadToEnd();

//Response.Write(fileContent);

//sr.Close();

//fs.Close();

DataTable dt1 = new DataTable();while (sr1.Peek() > -1)

{

line = sr1.ReadLine();

if (line.Trim() == string.Empty) continue;if (lineCount++ == 0)

{

string[] cols = line.Split(new string[] { "," }, StringSplitOptions.None);

for (int i = 0; i < cols.Length; i++)

{

//if (cols[i] == "ENV_CD") ENV_CD_COL_INDEX = i;

//if (cols[i] == "SITE") SITE_COL_INDEX = i;

//if (cols[i] == "FILER_NM") FILER_NM_COL_INDEX = i;

//if (cols[i] == "SHARE_TYPE") SHARE_TYPE_COL_INDEX = i;

DataColumn dc1 = new DataColumn(cols[i]);

dt1.Columns.Add(dc1);

}

}

else

{

string[] values = line.Split(new string[] { "," }, StringSplitOptions.None);

 

DataRow dr1 = dt1.NewRow();for (int i = 0; i < values.Length; i++)

{

dr1[i] = values[i];

}

dt1.Rows.Add(dr1);/////// ///////////////////////////////////////////////////the is the error the line point to when bindgrid() is executing   line 199

}

 

 

}

sr1.Close();

}

dt.Columns.Add(
"NewColumn");for (int j = 0; j < dt.Rows.Count; j++)

{

for (int k = 0; k < dt.Rows.Count; k++)

{

if (dt.Rows[j].ItemArray[40] == dt.Rows[k].ItemArray[3])

{

dt.Rows[j]["NewColumn"] = dt.Rows[k].ItemArray[11]; //

}

}

}

 

 

 

 

//drpEnvironment.DataSource = environment;

//drpEnvironment.DataBind();

//drpSite.DataSource = site;

//drpSite.DataBind();

//drpFiler.DataSource = filer;

//drpFiler.DataBind();

//drpShareType.DataSource = shareType;

//drpShareType.DataBind();

lblTotal.Text = dt.Rows.Count.ToString();

gvResults.DataSource = dt;

gvResults.DataBind();

}

 

 

</script>

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>NAS Filer Storage Weekly Trend Report</title>

 

</head>

<body >