Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I write query to DB in .NET C#.

If I use PHP I write:
SQL
$query = "SELECT * FROM users";
$query_run = mysql_query($query);
$query_row = mysql_fetch_assoc($query_run);
// intializate


I'm interesting in some analog on C#.
Posted

1 solution

Short answer: you need to use ADO.NET. I recommend this CodeProject article which provides a very good introduction to beginners:

Using ADO.NET for beginners[^].

For further learning, please see:
http://en.wikipedia.org/wiki/ADO.NET[^],
http://msdn.microsoft.com/en-us/library/h43ks021%28v=vs.100%29.aspx[^],
http://msdn.microsoft.com/en-us/library/aa286484.aspx[^].

—SA
 
Share this answer
 
Comments
Uday P.Singh 11-Mar-12 18:10pm    
Agree 5!, SA I need to ask you Where can I upload the source code of my article while submitting the article in codeproject?
Sergey Alexandrovich Kryukov 11-Mar-12 18:18pm    
Thank you, Uday.

In the wizard, there is an upload form, in the very beginning. You can get back to it in next step of the update. You should have article URL as soon as you submit it but not marked as final. From this URL, look somewhere in right top corner.
You also can edit the article in raw HTML and see where the code is referenced, modify this line to your liking.
--SA
Uday P.Singh 12-Mar-12 2:07am    
thanks for reply! I can upload source code using upload file, then what is "Article source Url"?
Sergey Alexandrovich Kryukov 12-Mar-12 12:31pm    
Sorry if I did not make clear. I don't remember some detail, but you can submit the article, using some URL to submit it through the Wizard. After you do it, you get exact same URL which will be your permanent article URL when you complete it, and when the article is edited. The only difference is the status of the article and your ability to change it. At first, the URL just does not appear in any of the lists of articles, but you will should already have this URL. Then you load your article as you load any other article, and on the right top corner you can see how to access it for editing. Later you claim that the article is ready, then it's being a subject of editing, and later on you cannot access modification of the article directly. You can update it by sending some e-mail...
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900