CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Nov 2008
    Location
    Wisconsin
    Posts
    16

    C# must have a bug

    I think C# has a bug because its being retarted.

    Code:
    using System;
    using System.Linq;
    using System.Windows.Forms;
    namespace Transaction{
    public partial class frmInventoryItems:Form {
    public frmInventoryItems() {
     InitializeComponent();
    }
    private void buttonRefresh_Click(object sender, EventArgs e) {
     TDataContext dContext = new TDataContext();
    dContext.InventoryItems InvItems = from i in dContext.InventoryItems select i;
    }
    }
    }
    I get an error on the red item, but the green item works just fine. That is impossible, and it is declared right above this line. There's no reason it should give an error. Even when I type a . after the red item I still get the popup list with the fields that belong to it.

    The type or namespace name 'dContext' could not be found (are you missing a using directive or an assembly reference?) 13
    - ITT Guy

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: C# must have a bug

    Quote Originally Posted by ITT Guy View Post
    I think C# has a bug because its being retarted.
    Actually the entire problem lies YORU code.

    Look at the message:
    The type or namespace name 'dContext' could not be found
    Your code has a variable named dContext.

    So your are attempting to define a NEW Variable "InvItems" of TYPE "dContext.InventoryItems", but we have already determined that dContext is NOT a TYPE!!!!!!

    Edited by Admin: Personal comments removed.
    Last edited by Brad Jones; November 17th, 2008 at 04:49 PM. Reason: Personal statement removed.
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Nov 2008
    Location
    Wisconsin
    Posts
    16

    Re: C# must have a bug

    Well anyway I wouldnt use LINQ because its just an easy way for someone to hack your program. An example from MSDN

    Code:
    protected void buttonSearch_Click(object sender, EventArgs e)
    {  
    using (NorthwindDataContext context = new NorthwindDataContext())  
    {    
    var customers = from c in context.Customers where (        
    c.ContactName.Contains(textBoxCustomerName.Text.Trim())  &&        
    c.CompanyName.Contains(textBoxCompanyName.Text.Trim()))  select c;      
    gridViewCustomers.DataSource = customers;      
    gridViewCustomers.DataBind();  
    }
    }
    Using data directly from a text box into a SQL query? LOL can someone say injection hacking? No one MS products always get hacked.
    - ITT Guy

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: C# must have a bug

    Quote Originally Posted by ITT Guy View Post
    Well anyway I wouldnt use LINQ because its just an easy way for someone to hack your program. An example from MSDN

    Code:
    protected void buttonSearch_Click(object sender, EventArgs e)
    {  
    using (NorthwindDataContext context = new NorthwindDataContext())  
    {    
    var customers = from c in context.Customers where (        
    c.ContactName.Contains(textBoxCustomerName.Text.Trim())  &&        
    c.CompanyName.Contains(textBoxCompanyName.Text.Trim()))  select c;      
    gridViewCustomers.DataSource = customers;      
    gridViewCustomers.DataBind();  
    }
    }
    There is NO "Using data directly from a text box into a SQL query?"

    There is [B]NO[B] susceptability to "injection hacking?"

    The simplicity of the above code, combined with the INHERENT safety is a large part of the benefit of LINQ-TO-SQL. (FYI: LINQ itself has NOTHING to do with SQL or any other database!)
    You are simply (AGAIN) showing your ignorance [three in a row...going for a record?]
    Last edited by TheCPUWizard; November 17th, 2008 at 04:57 PM. Reason: Fix tagging..
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    Jun 2008
    Posts
    2,477

    Re: C# must have a bug

    "It is never the compiler"

    the C# compiler has been tested much more than your code has and was written by very bright programmers. When you get to the point that you are blaming the compiler, just stop and blame yourself all over again.

  6. #6
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: C# must have a bug

    Quote Originally Posted by BigEd781 View Post
    "It is never the compiler"
    Never, say never...Otherwise I will lose my dream of winning a million dollarys in Wednesday's drawing, and again on Saturday, and again on next Weds.

    Anything is possible, but there are some things we just should not count on....

    ps: BigEd781...why don't you have private messaging enabled???
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  7. #7
    Join Date
    Jun 2008
    Posts
    2,477

    Re: C# must have a bug

    You're right, never say never. I say never because I have *almost* come to the point of blaming the compiler, and I had to remind myself that that is probably wrong and it is almost certainly my fault. It was, every time.

    I enabled private messages. I didn't know they were disabled by default. thanks.

  8. #8
    Join Date
    May 1999
    Location
    G day Mayt Land
    Posts
    971

    Re: C# must have a bug

    you guys have made ITT guy to think twice about posting in here.
    of course you blame the rest of teh world when you cant figure it out.
    this is a normal human behaviour.

  9. #9
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: C# must have a bug

    this is a normal human behaviour
    I hope not !

    If I drive my car into a lampost, I don't generally blame the lampost.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  10. #10
    Join Date
    Dec 2004
    Location
    Poland
    Posts
    1,165

    Re: C# must have a bug

    Quote Originally Posted by darwen View Post
    If I drive my car into a lampost, I don't generally blame the lampost.
    So you probably did not hear of a lady who sued microwave oven manufacturer AND WON because she killed her cat when she attempted to dry it in microwave. Or about some dude who sued car manufacturer AND WON, because he was so dense that he could not distinguish between cruise control and auto-pilot

    Or maybe these are just urban legends?
    B+!
    'There is no cat' - A. Einstein

    Use [code] [/code] tags!

    Did YOU share your photo with us at CG Members photo gallery ?

  11. #11
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940

    Re: C# must have a bug

    So you probably did not hear of a lady who sued microwave oven manufacturer AND WON because she killed her cat when she attempted to dry it in microwave. Or about some dude who sued car manufacturer AND WON, because he was so dense that he could not distinguish between cruise control and auto-pilot
    That was exactly my point. Do these people appear to be acting rationally ? They don't to me.

    Blaming everyone and everything else for one's own mistakes is irrational behaviour. If it were not the examples you've just given would be considered ordinary.

    Or at least I hope so...

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  12. #12
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: C# must have a bug

    Quote Originally Posted by Hobson View Post
    So you probably did not hear of a lady who sued microwave oven manufacturer AND WON because she killed her cat when she attempted to dry it in microwave. Or about some dude who sued car manufacturer AND WON, because he was so dense that he could not distinguish between cruise control and auto-pilot

    Or maybe these are just urban legends?
    To the best of my knowledge both are Urban Legends. Although....

    1) Do not discount companies who will settle a claim simply because it is cheaper than defending themselves in court. Technically this does not mean that they "Won", but more that it never came to trial, so they did not "Lose" (of course their bank account DID win!)

    2) There definately ARE some strange decisions made by the courts (speaking from a USA perspective)....

    3) SOme cases which appear "insane" on the surface are "skewed" by the media do gain attention. There may be underling "viable" reasons...
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  13. #13
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: C# must have a bug

    Quote Originally Posted by ITT Guy View Post
    Well anyway I wouldnt use LINQ because its just an easy way for someone to hack your program. An example from MSDN

    Code:
    protected void buttonSearch_Click(object sender, EventArgs e)
    {  
    using (NorthwindDataContext context = new NorthwindDataContext())  
    {    
    var customers = from c in context.Customers where (        
    c.ContactName.Contains(textBoxCustomerName.Text.Trim())  &&        
    c.CompanyName.Contains(textBoxCompanyName.Text.Trim()))  select c;      
    gridViewCustomers.DataSource = customers;      
    gridViewCustomers.DataBind();  
    }
    }
    Using data directly from a text box into a SQL query? LOL can someone say injection hacking? No one MS products always get hacked.

    sql injections can happen anywhere. you can write an SQL statement the same way, you can pass parameters to a sproc the same way. you can shoot your foot off the same way.


    poor coding has nothing to do with a language feature. It has to do with the programmer's inability to write good code; or even think for that matter.

  14. #14
    Join Date
    Nov 2007
    Location
    .NET 3.5 / VS2008 Developer
    Posts
    624

    Re: C# must have a bug

    Quote Originally Posted by ITT Guy View Post
    Well anyway I wouldnt use LINQ because its just an easy way for someone to hack your program. An example from MSDN

    Code:
    protected void buttonSearch_Click(object sender, EventArgs e)
    {  
    using (NorthwindDataContext context = new NorthwindDataContext())  
    {    
    var customers = from c in context.Customers where (        
    c.ContactName.Contains(textBoxCustomerName.Text.Trim())  &&        
    c.CompanyName.Contains(textBoxCompanyName.Text.Trim()))  select c;      
    gridViewCustomers.DataSource = customers;      
    gridViewCustomers.DataBind();  
    }
    }
    Using data directly from a text box into a SQL query? LOL can someone say injection hacking? No one MS products always get hacked.
    I would suggest you do a little more research into what LINQ actually is before posting about it again.

  15. #15
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Talking Re: C# must have a bug

    Quote Originally Posted by TheCPUWizard View Post
    Never, say never...Otherwise I will lose my dream of winning a million dollarys in Wednesday's drawing, and again on Saturday, and again on next Weds.

    Anything is possible, but there are some things we just should not count on....
    I really nearly falling from the chair. Hey you just have won CPUWizard - But dont forget to play Or how should god do his work
    Last edited by JonnyPoet; November 17th, 2008 at 02:05 PM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured