Update Statement
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Update Statement

Hybrid View

  1. #1
    Join Date
    Feb 2009

    Update Statement


    I want to update my statement to read 2 values from what is available -

    1) user_full_name (concatenation of firstname and lastname) eg., firstname = John lastname= Smith user_full_name = John Smith
    2) Initails (First letter of the firstname and first letter of the lastname) e.g., firstname = John lastname= Smith Initials = JS

    Please help me;

    ' Insert a new record into UserProfiles
            Dim connectionString As String = ConfigurationManager.ConnectionStrings("CCMSConnectionString").ConnectionString
            Dim updateSql As String = "UPDATE dbo.TblUser SET first_name=@FirstName, surname=@LastName, user_full_name=@user_full_name, Initials=@Initials WHERE UserId = @UserId"
            Dim fname, lname As String
            'Convert new entries to Title Case for consistancy
            fname = StrConv(FirstName.Text, vbProperCase)
            lname = StrConv(LastName.Text, vbProperCase)
            Using myConnection As New SqlConnection(connectionString)
                Dim myCommand As New SqlCommand(updateSql, myConnection)
                myCommand.Parameters.AddWithValue("@FirstName", fname.Trim())
                myCommand.Parameters.AddWithValue("@LastName", lname.Trim())
    myCommand.Parameters.AddWithValue("@user_full_name", XXXXXXXX)
    myCommand.Parameters.AddWithValue("@Initials", XXXXXXXX)
                myCommand.Parameters.AddWithValue("@UserId", newUserId)
            End Using

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Update Statement

    It should be pretty simple for you to figure out if you wrote the code you have already. It is simply a matter of combining the fname and lname in one case and in the other a matter of combining the first letter from each of those.

    Your question however is worded incorrectly as you are not reading anything with an update statement. Your values are coming from textboxes
    Always use [code][/code] tags when posting code.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a Codeguru.com survey!

HTML5 Development Center