System.Data.DataSet.Tables' is a 'property' but is used like a 'method'?

   

  private void PassID(string x)
    {
        //string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings("FasR6ConnectionString").ConnectionString;
        string strConnection = System.Configuration.ConfigurationManager.AppSettings["FasR6ConnectionString"].ToString();

        SqlConnection objConnection = new SqlConnection(strConnection);
        string query = "spGetEmail";

        SqlCommand objCommand = new SqlCommand(query, objConnection);
        objCommand.CommandType = CommandType.StoredProcedure;

        SqlParameter objParameter = new SqlParameter("@ID", SqlDbType.VarChar);
        objCommand.Parameters.Add(objParameter);
        objParameter.Direction = ParameterDirection.Input;
        objParameter.Value = x;


        SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand);
        DataSet objDataSet = new DataSet();
        objAdapter.Fill(objDataSet, "dtEmail");
       
//Error    1    'System.Data.DataSet.Tables' is a 'property' but is used like a 'method'  
    

  
        if (objDataSet.Tables("dtEmail").Rows.Count != 0)
        {

            ContactIdentifier = null;

            if (ContactIdentifiers.Find(objDataSet.Tables("dtEmail").Rows(0)("ContractorID").ToString) == null)
            {
                ContactIdentifier = ContactIdentifiers.Add();
                ContactIdentifier.EmailAddress = (objDataSet.Tables("dtEmail").Rows(0)("Email1").ToString);
            }
        }

    }

0
Fuziononline
10/28/2007 10:06:28 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

4 Replies
1024 Views

Similar Articles

[PageSpeed] 17

Hi Fuziononline, I suppose you are using c# instead of VB.Net. If i am right you should be using square [] brackets instead of using ()

the line objDataSet.Tables("dtEmail").Rows.Count != 0 instead of this use

objDataSet.Tables["dtEmail"].Rows.Count != 0. You have used () instead of [] in many places. If you correct them it should work fine.

Hope this helps

-Kishore

0
kishorevj
10/29/2007 11:12:15 AM

That did it. Thanks for the help!!

0
Fuziononline
10/29/2007 3:13:05 PM

 private void PassID(string x)
    {
        //string strConnection = System.Configuration.ConfigurationManager.ConnectionStrings("FasR6ConnectionString").ConnectionString;
        string strConnection = System.Configuration.ConfigurationManager.AppSettings["FasR6ConnectionString"].ToString();

        SqlConnection objConnection = new SqlConnection(strConnection);
        string query = "spGetEmail";

        SqlCommand objCommand = new SqlCommand(query, objConnection);
        objCommand.CommandType = CommandType.StoredProcedure;

        SqlParameter objParameter = new SqlParameter("@ID", SqlDbType.VarChar);
        objCommand.Parameters.Add(objParameter);
        objParameter.Direction = ParameterDirection.Input;
        objParameter.Value = x;


        SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand);
        DataSet objDataSet = new DataSet("dtEmail");
        objAdapter.Fill(objDataSet);


       
        if (objDataSet.Tables["dtEmail"].Rows.Count != 0)
        {

            ContactIdentifier = null;

            if (ContactIdentifiers.Find(objDataSet.Tables["dtEmail"].Rows[0]("ContractorID").ToString) == null)
            {
                ContactIdentifier = ContactIdentifiers.Add();
                ContactIdentifier.EmailAddress = (objDataSet.Tables["dtEmail"].Rows[0]("Email1").ToString);
            }
        }

    }

I'm getting a different error now. So you use [] to denote an array right? Is my syntax wrong here? 

0
Fuziononline
10/29/2007 10:11:50 PM

Hi Fuziononline, The column name that you use should also be in [] brackets.

ContactIdentifiers.Find(objDataSet.Tables["dtEmail"].Rows[0]["ContractorID"].ToString) == null

here the ContractorID is the column Name. So it should be the same as you are refering to a row.

Also the "ToString" should be put as "ToString()"

so here you have missed () after the ToString. So where ever you are calling a method it should have the () even if you are not sending any parameter to the method. For properties you dont have to put (). You better use the intellisense feature of Visual studio to know if you are using a property or a method.

In the intellisense you would find it something like this

Method - a method is denoted by a moving pink cube

Property - a property is denoted by a hand holding a page or Form kind of thing

Event - a lightning

Hope this helps

-Kishore

 

0
kishorevj
10/30/2007 8:29:30 AM
Reply:

Similar Artilces:

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

'System.Web.UI.IDataItemContainer.DataItem' is a 'property' but is used like a 'method'
On the line "<%# Container.DataItem("BlogID") %>", I get the error listed in the title of this post. I'm not sure why, I use this same for on other pages to get data from a database and I don't get this error.         <asp:GridView ID="GridView1"         runat="server"         AutoGenerateColumns="False"         DataKeyNames="BlogID"        D...

'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method'
 HI I have a datalist with OnItemDataBoundI get the following error when I try to get the DataItem 'System.Web.UI.WebControls.DataListItem.DataItem' is a 'property' but is used like a 'method' , any idea what's wrong with the line ?  public void Item_Bound(object sender, DataListItemEventArgs e)    {        Label originalPriceLabel;        if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem)        {    &n...

'System.Web.HttpContext.Session' is a 'property' but is used like a 'method
Hello, I'm trying to set my sessions into a class so I can set and access it easily. I get a 'System.Web.HttpContext.Session' is a 'property' but is used like a 'method' error, can you see what's wrong with my code ?  Thanks  public class SessionManager    {                public static bool isLogged        {            get        &nb...

is a 'property' but is used like a 'method'
Hi forum, I need some help! Ive converted a script from VB to C#. Come across the:  is a 'property' but is used like a 'method' CS0118 error. Ive searched about,  I should use [] not (). Im just not sure exactly where on this line of code, much thanks P  if ((Request("capability") != null) && (Request("userAgent") != null))   if (Request["capability"] != null && Request["userAgent"] != null)Encosia - ASP.NET, AJAX, and more.Latest article: Using complex types to make calling servic...

Can any one help due to this problem Error 1 'System.Web.UI.Page.Application' is a 'property' but is used like a 'method'
Hi all ! while creating application,session variables i am getting this problem can u suggest any one. Error 1 'System.Web.UI.Page.Application' is a 'property' but is used like a 'method'  lokesh   As a general guideline for seeking help, always show the code that is not working for you.  Your description alone is not enough for us to be able to help you. Alister kplokesh: Hi all ! while creating application,session variables i am getting this problem can u suggest any one. Error 1 'System.Web.UI.Page.Application' is a 'property' but is us...

System.Web.UI.Page.Cache is a 'property' but is used like a 'method'
if (Cache("MyData") == null){ds = myclasslibrary.lookupIDs();  <<filling datasetif (ds != null){if (ds.Tables[0].Rows.Count > 0){ddl.DataTextField = "Text";ddl.DataValueField = "ID";ddl.DataSource = ds;ddl.DataBind();Cache.Insert("MyData", ds, null,DateTime.Now.AddMinutes(5), Cache.NoSlidingExpiration);} }else{ds = ((DataSet) (Cache("MyData")));} error: System.Web.UI.Page.Cache is a 'property' but is used like a 'method'Its all about coding! Change the 2 lines that say Cache("MyData") to be Cache["MyData"] instead.If this post answered your question please remember to ...

'do' won't 'do' if '/'
Greetings to All from Au, Have a NetWare Perl 5.8.4 and wanted to tweak File\Spec\NW.pm to try and standardise on '/' separators. If I run a test script (t/uni/lower.t) with an unmodified NW.pm, it calls t/uni/case.pl, that, in case.pl, (when the path separators are '\'), the $file is '..\lib\unicore\To\Lower.pl' and the following code portion works, with $simple getting a returned table: sub casetest { my ($base, $spec, $func) = @_; my $file = File::Spec->catfile(File::Spec->catdir(File::Spec->updir, "lib", &qu...

CS0118: 'objDR' is a 'variable' but is used like a 'method' Error
Hi all , iam getting the above error when iam reading data using Reader can any body tell me what iam doing wrong . Here is code   public bool CheckCredentials(string Username, string Password) {     objConn.Open();     objCmd = new OleDbCommand("SELECT User_Name, Pass FROM Users WHERE User_Name=@givenUsername", objConn);     objCmd.Parameters.AddWithValue("@givenUsername", Username);     objDR = objCmd.ExecuteReader();     if (!objDR.Read()) {         return false;   &nbs...

'''
Name: L Lachowsky Email: e2brutus_10atyahoodotcom Product: Firefox Summary: ''' Comments: why duddn this surprise me... I change default server from IE to Mozilla, and then i get error messages. well, shud I decide to not get on my computer with Mozilla..or shud I risk security breeches with IE....hmmm at least i can get on the internet with IE Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this fee...

Error: foreach statement cannot operate on variables of type 'System.Data.DataSet' because 'System.Data.DataSet' does not contain a definition for 'GetEnumerator', or it is inaccessible
I am getting error on this line DataSet dsdata=new DataSet(); SQL="Seelct * from tablename"; //dsdata contains result of the above query foreach(DataRow dr in dsdata) //This line gives error Error: foreach statement cannot operate on variables of type 'System.Data.DataSet' because 'System.Data.DataSet' does not contain a definition for 'GetEnumerator', or it is inaccessible DataSet dsdata=new DataSet(); SQL="Select * from tablename"; //dsdata contains result of the above query foreach(DataRow dr in dsdata.Tables[0].Rows) //This ...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

convert type 'System.Data.DataSet' to 'System.Data.DataTable'
 I got this error  : Cannot implicitly convert type 'System.Data.DataSet' to 'System.Data.DataTable' i have written code like thisDataTable dt = new DataTable(); dt = GetGalleryImages(name); Possibly coz GetGalleryImages returns a dataset and not a datatable? Try: DataSet ds = GetGalleryImages(name); what type does GetGalleryImages return?  If this returns a dataset then you will have to change datatable to dataset, then index the table of the dataset.Please mark as answer if you find helpful.Ustes G....

Web resources about - System.Data.DataSet.Tables' is a 'property' but is used like a 'method'? - asp.net.getting-started

Resources last updated: 12/6/2015 4:59:28 AM