Advertisement

12.20.2007 at 01:52PM PST, ID: 23037087
[x]
Attachment Details

Update data from TextBoxes in vb.net to SQL Server

Asked by redouard in Visual Studio .NET 2003

Tags: textbox, data, sql, update, from

I have a aspx page and created a button to take the values from the textboxes and update the sql tables respectively. However, the updates aren't happening.
Here's my code:

        Try
            'Define database connection
            myconnection_1 = New SqlClient.SqlConnection("server=xxx;user=xxxx; password=rxxx;database = " & DropDownList1.SelectedItem.Value)
            myconnection_1.Open()

            Dim command As String
            Dim command2 As String

            Dim dbcommand As SqlCommand = New SqlCommand(command, myconnection_1)

            'set up an SQL update
            command = "update [user] set FirstName = '" & _
            TextBox1.Text & "', " & " LastName = '" & TextBox2.Text _
            & "', " & " Group = '" & DropDownList2.SelectedItem.Text _
            & "', " & " ProfessionalType = '" & DropDownList3.SelectedItem.Text _
            & " Password = '" & TextBox4.Text _
            & "' where UserName =  '" & TextBox6.Text & "'"

            Dim dbcommand2 As SqlCommand = New SqlCommand(command2, myconnection_1)

            command2 = "update [Professional] set FirstName = '" & _
            TextBox1.Text & "', " & " LastName = '" & TextBox2.Text _
            & "', " & " PatientGroupID = '" & DropDownList2.SelectedItem.Text _
            & "', " & " ProfessionalType = '" & DropDownList3.SelectedItem.Text _
            & "' where UserId =  (select userid from [user] where username = '" & TextBox6.Text & "'"

            'Execute stored procedures
            dbcommand.ExecuteNonQuery()
            dbcommand2.ExecuteNonQuery()

        Catch exceptionObject As Exception
            Label12.Text = ""
        Finally
            myconnection_1.Close()
        End Try
        Label12.Text = "Record has been Updated !"
    End SubStart Free Trial
[+][-]12.25.2007 at 06:01PM PST, ID: 20528177

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 07:12AM PST, ID: 20529393

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 07:36AM PST, ID: 20529467

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 07:58AM PST, ID: 20529554

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 09:57AM PST, ID: 20530072

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 01:33PM PST, ID: 20531046

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.26.2007 at 01:55PM PST, ID: 20531136

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Studio .NET 2003
Tags: textbox, data, sql, update, from
Sign Up Now!
Solution Provided By: arcee123
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628