Setting a value in a textbox

Discussion in 'ASP.NET / ASP.NET Core' started by lukesb, Nov 4, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi evryone

    I need to set the value of a text box to equal a field in my database, so it would kinda be like...

    textbox1.text = SELECT Hits FROM CustInf WHERE (AC = @Param1)

    Param1 is a textbox on my page that has the value from User.Identity.Name

    SO I need to get the value of Hits from the CustInf table for the logged in account in the textbox...

    Can anyone give me a pointer on this..?

    Cheers..!

    Luke
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    You would do something like this

    Dim dbconn as sqlconnection
    Dim dbCMD as sqlCommand
    Dim Hits as string
    dbConn = New SQLConnection ("Data Source=DBSERVERNAME;Initial Catalog=YOURDBNAME;User ID=YOURUSERID;Password=YOURPASSWORD")
    dbConn.open()
    dbCMD = new sqlcommand ("select * from tblTest",dbconn)
    Hits = dbCMD.executeScalar
    textbox1.text = hits.tostring
     
  3. Thanks Bruce...

    I have used the same method you've shown me to update and insert records to. Would that be the right way to do it..?

    Cheers mate..!

    Luke
     
  4. Bruce

    Bruce DiscountASP.NET Staff

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page