Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question How To Make Asp.net C# Database Connection

    Hello All,

    I am trying to develop a portal system (in ASP.NET with C#) which will simply take information from a textarea or other input and place it into an MSSQL database (when a submit button is pressed possibly). Then at a later time, I would like another page to be able to take that data from the MSSQL database and place it into the web page simply as text.

    I've found ways to do this with visual studio menus and so forth; however, I would much rather code the project as much as possible (only using software for shortcuts). Is there a way to (using C#) query data from an MSSQL database and place it into a variable (string or int) which can then be shown on the asp.net page? (and visa versa, insert variable information into a database)

    I am currently running MSSQL 2005 and Visual Studio 2008 (and the adobe cs3 suite if that helps)...on windows xp.

    I am open to learning anything necessary to make this happen. I already have a proficient knowledge of C#; therefore, I'd rather use that over VB if at all possible.

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    SqlConnection is the .net shortcut for working with mssql databases otherwise you can use an odbc connection.

    SqlConnection info:
    http://msdn2.microsoft.com/en-us/lib...on(VS.71).aspx

    ODBC info:
    http://msdn2.microsoft.com/en-us/lib...data.odbc.aspx

    SqlConnection will be much simpler to adjust to, just have a button that submits the form, find the value of of the box in the form and use the sql INSERT command on the object to append the data to the table.

    Then to put the data in another table, use the SELECT command on the object to find the data in the table you want & store the results in a variable, then either use objectName.InnerHTML or .InnerText or <&#37;= value %> depending on how your document is structured
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • Users who have thanked mjlorbet for this post:

    mirra1515 (04-06-2008)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •