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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2005
    Posts
    279
    Thanks
    0
    Thanked 0 Times in 0 Posts

    retrieve data from input box to table

    Say I have this code, but I want to retrieve from whatever the user inputs in the input box. php has $_POST feature, but I am not aware of asp.net.I want to get that input box (whatever the user entered) and store into my tblTest table.

    Code:
    Imports System.Data.SqlClient
    
    Partial Class _Default
        Inherits System.Web.UI.Page
    
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
            Dim ra As Integer
            Dim cnn As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("LocalSQLServer").ConnectionString)
            Dim cmd As New SqlCommand("insert into tblTest (NameID, Name) VALUES ('3', 'Test3')", cnn)
            'Dim qry As New SqlDataReader
    
            cnn.Open()
            ra = cmd.ExecuteNonQuery()
            Response.Write("Inserted!")
    
            cnn.Close()
        End Sub
    End Class

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Posts
    279
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello?

  • #3
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Please re-read the basic tutorial on how asp.net works, postbacks, etc.
    http://quickstarts.asp.net/QuickStar...t/Default.aspx

    That said, due to postback, you don't need anything at all to get it. It's there. Whatever you called your textbox, the Text property. It's stored in the view state and just referenced like
    myTextboxName.Text

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

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