2 Replies - 2102 Views - Last Post: 01 November 2014 - 10:38 PM Rate Topic: -----

#1 starlytpire   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 09-September 11

Inserting values of dynamically created textbox to sql server database

Posted 01 November 2014 - 10:17 AM

Hi. I'm trying to create a program that will store/insert the data inputted by the user in those dynamically created textboxes to the database. Im using Sql Server Ce as my database. I already managed to fetch the data from the textboxes but only the first input of the user is being inserted into the database; thus, if the user input red for textbox1 and yellow for textbox 2, only red will be inserted in the database twice. Here's what i have so far:

 Dim num As Integer

        num = Integer.Parse(numTextBox.Text)
        'numTextBox -> where user inputs how many textboxes the would like to create

        For i As Integer = 1 To num
           
            Dim userInput As TextBox
            userInput = addSubmittalPanel.Controls.Item("TextBox" & i.ToString)

            With cmd
                .Connection = dbconnect
                .CommandText = "INSERT INTO submittals_list_tbl(submittal_name) Values(@submittal_name)"
                .CommandType = CommandType.Text
                .Parameters.AddWithValue("@submittal_name", userInput.Text)
                .ExecuteNonQuery()
            End With
        Next




Thank you so much! i hope you can help me. :helpsmilie:

Is This A Good Question/Topic? 0
  • +

Replies To: Inserting values of dynamically created textbox to sql server database

#2 thecoat   User is offline

  • D.I.C Addict

Reputation: 153
  • View blog
  • Posts: 537
  • Joined: 07-December 13

Re: Inserting values of dynamically created textbox to sql server database

Posted 01 November 2014 - 11:10 AM

After line 16

.Parameters.Clear()

Was This Post Helpful? 1
  • +
  • -

#3 starlytpire   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 09-September 11

Re: Inserting values of dynamically created textbox to sql server database

Posted 01 November 2014 - 10:38 PM

View Postthecoat, on 01 November 2014 - 11:10 AM, said:

After line 16

.Parameters.Clear()


thank you very much! It's working now. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1