Retrieve data from textboxes and save them

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Benniit
    New Member
    • May 2008
    • 54

    Retrieve data from textboxes and save them

    'Already declared the DataSet as dtFile and SqlDataAdapter as daFile
    Code:
    Dim SqlQuery as String
    
    SqlQuery = "Select * from FileRegister where FILE_NO='" & frmBsearch.txtFileNo.Text.Trim & "'"
    
    daFile = New SqlClient.SqlDataAdapter(SqlQuery , SQLConnection)
    daFile.Fill(dtFile , "FileRegister")
    
    
    frmBsearch.txtSPrefix.DataBindings.Add("text", dtFile, "FileRegister.Prefix")
    frmBsearch.txtSPlotNo.DataBindings.Add("text", dtFile, "FileRegister.Plot_No")
    frmBsearch.txtSBlockNo.DataBindings.Add("text", dtFile, "FileRegister.Block_No")
    So please how can I add a new row and save those records in the TextBoxes?

    ben
    Last edited by Frinavale; Apr 3 '09, 06:41 PM. Reason: Added [code] tags. Please post code in [code] [/code] tags.
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    You cannot save a TextBox in a database.
    You can save the Text within the TextBox into a database using the SQL insert into command.

    Also, you cannot save TextBoxes into a DataSet. You cannot actually save a row in a DataSet either because a DataSet is a collection of DataTables (loaded in memory). You can add a row to a DataTable (in your DataSet) using the Text from the TextBoxes; however, you cannot add a TextBox itself to the table.

    Comment

    • Benniit
      New Member
      • May 2008
      • 54

      #3
      Retrieve values of textbox and save them into a database

      So please how can I save the text in textboxes into the database. As the data is retrieved into the textboxes as shown below and I want to save them.
      Thank you.
      Code:
          Dim SqlQuery as String
         
         SqlQuery = "Select * from FileRegister where FILE_NO='" & frmBsearch.txtFileNo.Text.Trim & "'"
          
         daFile = New SqlClient.SqlDataAdapter(SqlQuery , SQLConnection)
         daFile.Fill(dtFile , "FileRegister")
           
          
        frmBsearch.txtSPrefix.DataBindings.Add("text", dtFile, "FileRegister.Prefix")
        frmBsearch.txtSPlotNo.DataBindings.Add("text", dtFile, "FileRegister.Plot_No")
        frmBsearch.txtSBlockNo.DataBindings.Add("text", dtFile, "FileRegister.Block_No")
      Last edited by Frinavale; Apr 6 '09, 01:32 PM. Reason: Added [code] tags. Please post code in [code] [/code] tags.

      Comment

      • truezplaya
        New Member
        • Jul 2007
        • 115

        #4
        Take the text box data and assign it in to some variable

        Dim variable1 as string = textbox1.text

        Use an SQL statement INSERT

        INSERT INTO table_name
        VALUES (Variable1)

        If you are unsure check out
        W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.



        All you seem to be doing in your SQL statement is getting data back from the DB. I think you may need to read up on some simple SQL this will help you immensly

        Truez

        Comment

        Working...