• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

ASP.net C# and SQL headache

LBJuice

n00b
Joined
Jan 23, 2005
Messages
27
I normally use PHP/MySQL but today I'm making an ASP.net web application for work and visual studio tries (at least to my understanding) to hard to make it easy by providing menus and GUI's that writes code for you.

I searched Google for examples of ASP.NET using C# for making SQL driven web pages, but I wasn't able to find something helpful, mostly forums of broken code and people wondering what was wrong or tutorials that show you how to use the menus to work with data. (I tried this, it was to confusing I would rather work with code)

Pretty much if someone could post sample code of how to:
1 ) Connect to a database and display a println for sucess/error (so I can test my own)
2.) Run a simple query (SELECT * FROM database)
3.) Show how to structure that data so it can be displayed (so it can be binded to a listbox or outputted to plain text)

I'm not asking someone to write it for me, but if you have code or know of a tutorial that can illustrate the basics of running SQL queries/displaying results that would help me out greatly. I work far better by finding working code, and then playing with it to see how it works.
 
MSDN included with Visual Studio has samples for what you are looking for.

This is the same example included in the documentation (see the [c#] section): http://msdn2.microsoft.com/en-us/library/aa719634(VS.71).aspx

As a "bonus" you don't even need to use that icky GUI that Visual Studio that "tries (at least to my understanding) to hard to make it easy by providing menus and GUI's that writes code for you." :p In a standard VS ASP.NET Web Application project you get a blank form to put components in and a little glue to create and initialize a little overhead. You can see how little code is automatically generated in the "Web Form Designer generated code" section of the form's .cs file (it only hooks up the Page_Load event and calls the base.OnInit()).

ASP.NET is not PHP at all. The video linked above is only a few minutes long and it's probably worth checking out all the others that are related to what you're trying to accomplish. The datagrid is a really nice component that has a lot of functionality for what is output as a HTML table.
 
Back
Top