|
-
November 16th, 2008, 07:21 PM
#1
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
-
November 16th, 2008, 07:27 PM
#2
Re: C# must have a bug
 Originally Posted by ITT Guy
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
-
November 16th, 2008, 07:51 PM
#3
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
-
November 16th, 2008, 07:57 PM
#4
Re: C# must have a bug
 Originally Posted by ITT Guy
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
-
November 16th, 2008, 08:20 PM
#5
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.
-
November 16th, 2008, 08:32 PM
#6
Re: C# must have a bug
 Originally Posted by BigEd781
"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
-
November 16th, 2008, 08:48 PM
#7
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.
-
November 16th, 2008, 11:52 PM
#8
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.
-
November 17th, 2008, 06:56 AM
#9
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.
-
November 17th, 2008, 07:54 AM
#10
Re: C# must have a bug
 Originally Posted by darwen
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 ?
-
November 17th, 2008, 08:07 AM
#11
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.
-
November 17th, 2008, 08:18 AM
#12
Re: C# must have a bug
 Originally Posted by Hobson
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
-
November 17th, 2008, 10:40 AM
#13
Re: C# must have a bug
 Originally Posted by ITT Guy
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.
-
November 17th, 2008, 11:21 AM
#14
Re: C# must have a bug
 Originally Posted by ITT Guy
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.
-
November 17th, 2008, 01:56 PM
#15
Re: C# must have a bug
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|