set and get method to connect to a sql database in C#

assaultkitty
assaultkitty used Ask the Experts™
on
I need an example on how get and set method to retrieve information from a sql database.  If you have available documentation available.  This is information is for homework.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015
Commented:
The Microsoft MSDN site is a great resource for such things. This is from a simple Google search.

If you look at the section called "To execute an SQL statement returning a single value using a DataCommand" on this page.

http://msdn.microsoft.com/en-us/library/eeb84awz(v=vs.80).aspx

In your case you can use int returnValue; instead of Object returnValue; since you will be wanting an integer to satisfy your set/get property.

Put that code into a new function in your SimpleProperty class file and have it return an integer value. Then just call the function in your get portion of the set/get property.

Post your version of the code if you have difficulties.

Author

Commented:
I am sorry I was googling set and method sqldatabase.

Author

Commented:
I have not used or seen a table adapter.  No example or explain in book.  thanks.
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Top Expert 2015

Commented:
Not suggesting the TableAdapter method. You are looking at the wrong section of the page I cited. Look at the Command Object section.

Author

Commented:
I see it.  thanks.

Author

Commented:
tommyboy, you are true expert and teacher.  I have the program up and running.  It is not connected to the database.  So, I am going to start another question.  You solved this question.
hitcounter.docx
Top Expert 2015

Commented:
Thanks. When you raise three children to adulthood, you cannot help but gain some teaching skills.

Author

Commented:
I really appreciate it.  I did not have a C# class prior to doing this class so I am learning two things at once.  Thanks again.

Author

Commented:
Got to do the right thang!
Top Expert 2015

Commented:
You did it, thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial