Results 1 to 3 of 3

Thread: [help] update data to Sql Server

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    39

    [help] update data to Sql Server

    Hi, this time I wan to update tables in my database called "Table". and a session called "MemberDetail" which just contains "id" and "password". Now i want to update the info of Address and City in Table. What code can i use in this case? Can anyone helps me with some codes please? Urgent and thanks.=)
    Last edited by asp.net; Mar 6th, 2006 at 12:39 PM. Reason: wrong title

  2. #2

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    39

    Re: [help] update data to Sql Server

    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click

    Dim SqlCommand As SqlCommand = New SqlCommand
    sqlConnection.Open()
    SqlCommand.Connection = sqlConnection
    Dim sSQL As String
    sSQL = "SELECT * FROM Employee_Contact WHERE EmployeeName = @username"

    Try
    SqlCommand.CommandText = "UPDATE Employee_Contact SET EmployeeID = '" & txtEmpID.Text & "' & EmpAddress= '" & txtEmpAddress.Text & "' & EmpCity ='" & txtEmpCity.Text & "' & EmpZipCode ='" & txtEmpZipCode.Text & "' & EmpState = '" & ddlEmpState.SelectedItem.Value & "' WHERE EmployeeName = @username"
    SqlCommand.ExecuteNonQuery()
    Catch ex As Exception
    Finally
    If (sqlConnection.State = ConnectionState.Open) Then
    sqlConnection.Close()
    End If
    End Try
    End Sub
    End Class
    What's wrong with my code? Y i cannot update, cannot run.Search for help, Thanks.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    39

    Re: [help] update data to Sql Server

    anyone here can guild me how to use dataAdapter n dataReader these things?add at where? tq.

Posting Permissions

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



Click Here to Expand Forum to Full Width