troubleshooting Question

CS0118: 'arrFields' denotes a 'variable' where a 'method' was expected

Avatar of ybchen_1999
ybchen_1999 asked on
ASPWindows XPC#
10 Comments5 Solutions670 ViewsLast Modified:
Converted VB code to C# got error using VBConversion software
CS0118: 'arrFields' denotes a 'variable' where a 'method' was expected
Please see the following code
Visual Studio 2003
Window XP
Thanks in advance
Ben Chen
==========================================================================
using Microsoft.VisualBasic;
using System.Data;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System;
using System.Collections;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Drawing;

namespace WebStore
{
      public class admin_company_info : System.Web.UI.Page
      {
            
            protected System.Web.UI.WebControls.TextBox txtWelcome;
            protected System.Web.UI.WebControls.TextBox txtCompanyName;
            protected System.Web.UI.WebControls.TextBox txtAddress;
            protected System.Web.UI.WebControls.TextBox txtPhoneNumber;
            protected System.Web.UI.WebControls.TextBox txtRegionalTaxRate;
            protected System.Web.UI.WebControls.TextBox txtCity;
            protected System.Web.UI.WebControls.TextBox txtFaxNumber;
            protected System.Web.UI.WebControls.TextBox txtFederalTaxRate;
            protected System.Web.UI.WebControls.TextBox txtRegion;
            protected System.Web.UI.WebControls.TextBox txtEmailAddress;
            protected System.Web.UI.WebControls.TextBox txtMailServer;
            protected System.Web.UI.WebControls.TextBox txtCountry;
            protected System.Web.UI.WebControls.TextBox txtAdminEmailAddress;
            protected System.Web.UI.WebControls.TextBox txtLogin;
            protected System.Web.UI.WebControls.TextBox txtPostalCode;
            protected System.Web.UI.WebControls.TextBox txtCurrency;
            protected System.Web.UI.WebControls.TextBox txtPassword;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator3;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator5;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator6;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator7;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator8;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator9;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator10;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator11;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator12;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator13;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator14;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator15;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator16;
            protected System.Web.UI.WebControls.ValidationSummary ValidationSummary1;
            protected System.Web.UI.WebControls.Button cmdSave;
            protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator17;
            protected System.Web.UI.WebControls.TextBox txtLogoFile;
            protected System.Web.UI.WebControls.RequiredFieldValidator valLogoFile;
            protected System.Web.UI.WebControls.Label lblStatus;
            
            #region " Web Form Designer Generated Code "
            
            //This call is required by the Web Form Designer.
            [System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
            {

            }
            
            private void Page_Init(System.Object sender, System.EventArgs e)
            {
                  //CODEGEN: This method call is required by the Web Form Designer
                  //Do not modify it using the code editor.
                  InitializeComponent();
            }
            
            #endregion
            
            private void Page_Load(System.Object sender, System.EventArgs e)
            {
                  //Put user code to initialize the page here
                  if (System.Convert.ToBoolean(Session["AdminLogin"]) == false)
                  {
                        Response.Redirect("admin_login.aspx");
                  }
                  if (! IsPostBack)
                  {
                        LoadData();
                  }
            }
            
            private void LoadData()
            {
                  try
                  {
//                  Dim arrFields As Array = Split("CompanyName,LogoFile,Address,City,Region,PostalCode,Country,PhoneNumber,FaxNumber,EmailAddress,AdminEmailAddress,Currency,RegionalTaxRate,FederalTaxRate,MailServer,Login,Password", ",")
//                        string [] split = words.Split(new Char [] {' ', ',', '.', ':'});

                        Array arrFields = "CompanyName,LogoFile,Address,City,Region,PostalCode,Country,PhoneNumber,FaxNumber,EmailAddress,AdminEmailAddress,Currency,RegionalTaxRate,FederalTaxRate,Login,Password,MailServer".Split(',');

                        System.Data.OleDb.OleDbDataReader DTR;
                        string SQL;
                        SQL = "Select * From tblCompanyInformation";
                        System.Data.OleDb.OleDbCommand CMD = new System.Data.OleDb.OleDbCommand(SQL, (System.Data.OleDb.OleDbConnection) Session["DBCon"]);
                        DTR = CMD.ExecuteReader(CommandBehavior.Default);
                        DTR.Read();
                        long arrLoop;
                        for (arrLoop = arrFields.GetLowerBound(0); arrLoop <= arrFields.GetUpperBound(0); arrLoop++)
                        {
                              TextBox ctrl;
                              ctrl = this.FindControl("txt" + arrFields(arrLoop));
                              ctrl.Text = DTR[arrFields(arrLoop)];
                        }
                        DTR.Close();
                  }
                  catch (System.Exception ex)
                  {
                        GlobalCode.ErrReport(ex, Request.ServerVariables["REMOTE_ADDR"] + "<BR>" + Session["WebTitle"]);
                  }
            }
            private void Update()
            {
                  try
                  {
                        Array arrFields = "CompanyName,LogoFile,Address,City,Region,PostalCode,Country,PhoneNumber,FaxNumber,EmailAddress,AdminEmailAddress,Currency,RegionalTaxRate,FederalTaxRate,MailServer,Login,Password".Split(',');
                        System.Data.OleDb.OleDbDataReader DTR;
                        string SQL;
                        SQL = "Update tblCompanyInformation Set [CompanyName]=@CompanyName, [LogoFile]=@LogoFile, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country, [PhoneNumber]=@PhoneNumber, [FaxNumber]=@FaxNumber, [EmailAddress]=@EmailAddress, [AdminEmailAddress]=@AdminEmailAddress, [Currency]=@Currency, [RegionalTaxRate]=@RegionalTaxRate, [FederalTaxRate]=@FederalTaxRate, [MailServer]=@MailServer, [Login]=@Login, [Password]=@Password";
                        System.Data.OleDb.OleDbCommand CMD = new System.Data.OleDb.OleDbCommand(SQL, (System.Data.OleDb.OleDbConnection) Session["DBCon"]);
                        CMD.CommandText = SQL;
                        long arrLoop;
                        for (arrLoop = arrFields.GetLowerBound(0); arrLoop <= arrFields.GetUpperBound(0); arrLoop++)
                        {
                  //            CMD.Parameters.Add("@" + arrFields[arrLoop], arrFields[arrLoop]);
                              CMD.Parameters.Add("@" + arrFields.GetValue(arrLoop), arrFields.GetValue(arrLoop));
                              TextBox ctrl;
                              ctrl = this.FindControl("txt" + arrFields(arrLoop));
                              CMD.Parameters["@" + arrFields(arrLoop)].Value = ctrl.Text;
                        }
                        CMD.ExecuteNonQuery();
                        ///''  Response.Write(SQL)
                        this.lblStatus.Text = "Changes Saved to Database";
                  }
                  catch (System.Exception ex)
                  {
                        GlobalCode.ErrReport(ex, Request.ServerVariables["REMOTE_ADDR"] + "<BR>" + Session["WebTitle"]);
                  }
            }
            
            private void cmdSave_Click(System.Object sender, System.EventArgs e)
            {
                  Update();
            }
      }
      
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 5 Answers and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 5 Answers and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros