Connect the textbox with database in C# Express2010

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 3692 Views - Last Post: 16 May 2011 - 11:53 AM Rate Topic: -----

#1 Algorithms  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-May 11

Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 10:45 AM

Hello every one,
I am beginner in C# Express, and I have a project that I should complete as soon as possible using this language.
I have a textbox for the age that the user enter, then the value of age should be compared with the values stored in the database to retrieve the result. But I do not know how to create the database neither I do not know how to connect the textbox with the database for comparison and retrieving.
Any help please??? :unsure: :unsure:

Thanks,
Algorithms

This post has been edited by Curtis Rutland: 16 May 2011 - 10:48 AM
Reason for edit:: Removed unnecessary formatting


Is This A Good Question/Topic? 0
  • +

Replies To: Connect the textbox with database in C# Express2010

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 10:48 AM

Database tutorials right here on DIC


Standard resources, references and suggestions for new programmers.


I would recommend you start with "Hello World" just like the other million+ coders out there. Then work your way up to the more advanced tasks like this.

The problem with taking on large, complex tasks like this when you are new to coding is that
  • it will frustrate you to the point of quitting,
  • you don't know enough about coding to know where to start or in what direction to design your program
  • You risk learning via the 'Swiss cheese' method where you only learn certain bits and pieces for the one project but have huge holes in your education.


I am going to guess that you are trying to teach yourself C# without much guidance, a decent book or without knowing where to look. Sometimes just knowing where to look can make all the difference. Google is your friend.
Search with either "C#" or "MSDN" as the first word: "MSDN Picturebox", "C# Custom Events", "MSDN timer" etc.

But honestly, just typing away and seeing what pops up in Intellisense is going to make your self-education take 20 years. You can learn by trying to reverse engineer the language through banging on the keyboard experimentation - or you can learn by doing the tutorials and following a good "How to learn C#" book.

Free editions of Visual Studio 2010

May I suggest picking up a basic C# introductory book? There are so many great "How do I build my first application" tutorials on the web... There are dozens of "Learn C# in 21 days", "My first C# program" type books at your local book seller or even public library.

D.I.C. C# Resource page Start here
Intro to C# online tutorial then here...
C# control structures then here.
MSDN Beginner Developer video series
MSDN video on OOP principals, making classes, constructors, accessors and method overloading
MSDN Top guideline violations, know what to avoid before you do it.

The tutorials below walk through making an application including inheritance, custom events and custom controls.
Bulding an application - Part 1
Building an application - Part 2
Quick and easy custom events
Passing values between forms/classes

Working with environmental variables

Debugging tutorial
Debugging tips
Great debugging tips
It still doesn't work, article

Build a Program Now! in Visual C# by Microsoft Press, ISBN 0-7356-2542-5
is a terrific book that has you build a Windows Forms application, a WPF app, a database application, your own web browser.

C# Cookbooks
Are a great place to get good code, broken down by need, written by coding professionals. You can use the code as-is, but take the time to actually study it. These professionals write in a certain style for a reason developed by years of experience and heartache.

Microsoft Visual Studio Tips, 251 ways to improve your productivity, Microsoft press, ISBN 0-7356-2640-5
Has many, many great, real-world tips that I use all the time.

Writing a text file is always one of the first things people want to do, in order to store data like high-scores, preferences and so on
Writing a text file tutorial.
Reading a text file tutorial.


These are just good every-day references to put in your bookmarks.
MSDN C# Developers Center with tutorials
Welcome to Visual Studio

Have you seen the 500+ MSDN Code Samples? They spent a lot of time creating samples and demos. It seems a shame to not use them.

Let me also throw in a couple tips:
  • You have to program as if everything breaks, nothing works, the cyberworld is not perfect, the attached hardware is flakey, the network is slow and unreliable, the harddrive is about to fail, every method will return an error and every user will do their best to break your software. Confirm everything. Range check every value. Make no assumptions or presumptions.
  • Take the extra 3 seconds to rename your controls each time you drag them onto a form. The default names of button1, button2... button54 aren't very helpful. If you rename them right away to something like btnOk, btnCancel, btnSend etc. it helps tremendously when you make the methods for them because they are named after the button by the designer.
    btnSend_Click(object sender, eventargs e) is a lot easier to maintain than button1_click(object sender, eventargs e)
  • You aren't paying for variable names by the byte. So instead of variables names of a, b, c go ahead and use meaningful names like Index, TimeOut, Row, Column and so on. You should avoid 'T' for the timer. Amongst other things 'T' is commonly used throughout C# for Type and this will lead to problems. There are naming guidelines you should follow so your code confirms to industry standards. It makes life much easier on everyone around you, including those of us here to help. If you start using the standards from the beginning you don't have to retrain yourself later.

Was This Post Helpful? 0
  • +
  • -

#3 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 3831
  • View blog
  • Posts: 6,476
  • Joined: 08-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 10:50 AM

Here's a good, in-depth but easy to read series of articles about using DBs in C#.

http://www.csharp-st...t/Lesson01.aspx

Read through them and see if you can figure it out.
Was This Post Helpful? 2
  • +
  • -

#4 Algorithms  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-May 11

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 10:52 AM

Is there anyone else could help me gently?
Thank you,
Algorithms
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:18 AM

View PostAlgorithms, on 16 May 2011 - 11:52 AM, said:

Is there anyone else could help me gently?
Thank you,
Algorithms


What kind of 'help' is it you are looking for? We've already provided numerous tutorials to get you going and you haven't shown that you've put forth any effort in trying to code this for yourself.

We are not here to write it for you. You actually have to make an effort to do your own coding then we will help you when you get stuck. But from what you've written you want your first program to big this big database driven application and you have to have it done right away.

Like I said in the earlier post, do what all the other programmers in the world did: Start with 'Hello World' and go from there. You're going to actually have to learn to program in order to write this. It is not a simple copy/paste situation.

This post has been edited by tlhIn`toq: 16 May 2011 - 11:20 AM

Was This Post Helpful? 0
  • +
  • -

#6 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 3831
  • View blog
  • Posts: 6,476
  • Joined: 08-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:19 AM

What do you mean? I gave you a tutorial, have you tried working through it?
Was This Post Helpful? 2
  • +
  • -

#7 Algorithms  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-May 11

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:24 AM

tlhIn`toq ... I am not Indian first of all. Second thing I did not say that I want some one to write the code for me. Third thing I am not an employee. Forth thing Speak polite with the others please.

Curtis Rutland... Thanks I just saw your comment :) I have my own code already but the problem is that I do not know how to connect it with the database? Thanks anyways
Was This Post Helpful? 0
  • +
  • -

#8 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:26 AM

View PostCurtis Rutland, on 16 May 2011 - 12:19 PM, said:

What do you mean? I gave you a tutorial, have you tried working through it?


Oh, of course he did. It only took him 26 minutes from when you posted the tutorial link to when he asked for more help. That must be some kind of record time to actually work through a complete database tutorial, doing all the builds and creations.
Was This Post Helpful? 0
  • +
  • -

#9 Algorithms  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-May 11

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:29 AM

Why you are speaking with me in this manner??? no one forced you to answer me!!! Speak in polite way or keep silent please.
Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:31 AM

View PostAlgorithms, on 16 May 2011 - 12:24 PM, said:

I have my own code already but the problem is that I do not know how to connect it with the database? Thanks anyways


And after looking at all the tutorials we have here and the article that Curtis pointed you to you still weren't able to find anyplace where any of them showed how to connect to a database?

I find that highly doubtful.

So I'll ask again... What kind of help are you asking for, above and beyond all the articles and tutorials you've been given already? Because it seems like you don't want to be bothered with going through the tutorials to learn or find the info you need, but instead would prefer someone just give you a line of code showing you how to connect. And I'd like to believe that I'm just mis-interpreting your statements and that you are actually interested in LEARNING.

So what more gentle help are you asking for?
Was This Post Helpful? 0
  • +
  • -

#11 Algorithms  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 16-May 11

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:33 AM

I won't reply you anymore. I will discusses my question with polite people only :)

Thanks :)
Was This Post Helpful? 0
  • +
  • -

#12 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:33 AM

View PostAlgorithms, on 16 May 2011 - 12:29 PM, said:

Why you are speaking with me in this manner??? no one forced you to answer me!!! Speak in polite way or keep silent please.


There are many different kinds of nebiew posters on DIC.

By far the majority of newbies are people asking for code that solves their needs/homework. It doesn't seem to matter to these people that DIC has posted all over the place "We won't do you homework" and "You need to provide your good faith effort to code a solution to your problem." These people have already demonstrated with their first post a complete disrespect for the site rules and by extension the people on the site. They have also demonstrated their view of the volunteers here as being their personal code generation servants. Since these people have already insulted everyone on DIC with their arrogance it is not surprising that I or anyone else respond in the same manner in which they started their topic.

Next come the people that aren't exactly looking for a complete code dump of the solution. These are the people that are just too lazy to google and experiment and do tutorials or too lazy to learn before trying. They just start typing and *think* they know what a function should do based on nothing more than the name of the function. Then when it doesn't work as expected they declare it broken and ask for help to get around the *problem*, without every trying to look it up on MSDN or crack open a book. This doesn't disrespect the site, but it does disrespect the volunteers by reducing them to the OP's research slaves. Again, it's not unreasonable to expect a volunteer to respond with a tone of "I'm not your goggle-bot. Try looking it up and following the example."

Next comes the rare person who has made an effort. This highly prized newbie is working through a book or on-line tutorial... get's stuck {usually on something poorly documented}... takes it upon themselves to research... does their own trial and error... But still can't get an answer so they are left with having to ask for help. In my book these are the only type of people that will every amount to anything in the coding world (but that is personal opinion). This rare third type of newbie is someone that we all like to see, want to see more of, and we do our best to give as much attention and patience as we can muster. Can I get a 'Hell ya!' ?

It should also be considered that being frank and honest with someone is not the same as being rude. Just because a volunteer doesn't blow rainbows and sunshine up someone's skirt doesn't mean they are rude. Honestly advising a student they lack any amount of understanding on a topic, and they need to seek out the teacher or tutor is not rude. It is frank honesty, aimed at convincing them to seek help so they don't become further lost and waste more time and money while loosing out on an education.

As frank as I have been with a lot of newbies, I don't think you could find an instance where even *I* have called someone stupid. Lazy perhaps. But it is not in my nature to call someone stupid. I know I have suggested (more than once even) that someone might not be equipped for programming as a profession. Some people might think that rude. That may not be what someone wants to hear. But it could be what they *need* to hear. Some people really don't have what it takes. I would not be a good airline pilot or food server: I'd kill someone by the end of a day at food service. Some people are not equipped to be cops, or air traffic tower controllers. Should those people receive nothing but encouraging but polite lies? I think not. At some time all people have to grow up and accept frank honesty and a realistic self-image of their capabilities.
Was This Post Helpful? 0
  • +
  • -

#13 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 3831
  • View blog
  • Posts: 6,476
  • Joined: 08-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:36 AM

View PostAlgorithms, on 16 May 2011 - 01:24 PM, said:

Curtis Rutland... Thanks I just saw your comment :) I have my own code already but the problem is that I do not know how to connect it with the database? Thanks anyways


I don't understand how that matters. Of course you have your own code. But you don't know how to write code that connects to the database.

So do the tutorial, and you'll learn how to write code that connects to the database. Then you can go back and modify your old code to make it work.

And I don't see where anyone called you "Indian." I'm not sure where you're getting that.

tlhIn`toq has given you good advice, and many, many resources. He's frustrated that instead of looking at it, or what I posted, you asked for different help right away. He's a sarcastic guy, but he's always got good advice. After all, they respected him enough here to give him an "Expert" badge. So I suggest not getting so easily offended. This is the real world, not everybody has to be nice to you.
Was This Post Helpful? 0
  • +
  • -

#14 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 4963
  • View blog
  • Posts: 10,558
  • Joined: 02-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:43 AM

View PostCurtis Rutland, on 16 May 2011 - 12:36 PM, said:

And I don't see where anyone called you "Indian." I'm not sure where you're getting that.


In fairness to the OP my original comment said something about this feeling like an Indian outsource company post, where the employee lacks the skill or is just trying to get others to do the work they underbid on so they can get paid.

The OP would have read that in the email notification of a response to his question.

I had no more than hit send, when I realized how that sounded and edited the post to be less accusatory about it being an outsourcer's post. I assume the OP read the message in email and not the finished/edited post.
Was This Post Helpful? 0
  • +
  • -

#15 Curtis Rutland  Icon User is online

  • (╯°□°)╯︵ (~ .o.)~
  • member icon


Reputation: 3831
  • View blog
  • Posts: 6,476
  • Joined: 08-June 10

Re: Connect the textbox with database in C# Express2010

Posted 16 May 2011 - 11:45 AM

Ah.

Anyway, this thread is really getting out of hand. Let's keep all further replies on track and on topic.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2