how do you use code behind to query a database?


I have a user text box and a password text box on a page with a submit button. When a user enters their user name and password and hits submit, it should simply go and query a table called users for that individual. I can't figure out how to tell the SUBMIT button to do that. I guess I would have simply double clicked on the submit button in visual studio to get the code behind code but I don't know:
1. what the ID should be for the submit button so visual studio populates the generic code that I need.
2. What code I need to pull the columns user and password from the users table and where that code goes.

3. The result set will obviously have to wait . I plan on just returning the persons information--like displaying some other information about the user on a second page. They will not be logging into anything. I am just playing around with actually getting data from the database that I already have setup. Sorry if this posted in the wrong area...I'm guessing this is very newbie material



  • Hi,
    Actually it's a very common question that is asked by every user who enters in .net area.
    You have to just double click on submit button. A code behind page will be opened in front of you and a event would be there for coding. Just write your database connectivity code and function whatever you want to perform. But if you want to database connectivity code then you have to mention the database which you are using like ms-access, sql server or oracle etc.
    If you need to more clarification then feel free to contact me
    [email protected]

    Neeraj Gupta
    Software Developer
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion