Update Database ?

kcwallace

Centurion
Joined
May 27, 2004
Messages
175
Location
Austin, TX
Why won't the Code read a textbox?

I have a textbox "FName". When I run the following code from a button, the new value in the textbox does not get stored into the SQL string.

Visual Basic:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Cnn As New SqlConnection("Persist Security Info=False;Integrated Security=SSPI;database=suicidepool;server=kwallace")
        Cnn.Open()

        Dim x As String
        x = FName.Text.ToString
        Dim CmdRS As SqlClient.SqlCommand
        Dim UserSQL As String = "UPDATE UserData SET [UserName]=N'" & UName.Text & "', [FullName]=N'" & FName.Text & "', [EMail]=N'" & EMail.Text & "' WHERE [ID] = " & UIDtxt.Text

        CmdRS = New SqlClient.SqlCommand(UserSQL, Cnn)
        CmdRS.ExecuteNonQuery()
        Cnn.Close()
    End Sub

The SQL statement reads(FName was changed to "eee"):

UPDATE UserData SET [UserName]=N'kcwallace', [FullName]=N'n', =N'' WHERE [ID] = 1
 
Last edited:
Back
Top