CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    223

    Updating an encrypted string

    Hello ,
    Iam using VB.NET for db programming. I have an encrypted field in the tabe as a Text field. I can create a record and add a 16-bit encrypted string to the db. But,updating the record seems to be a problem. Th encrypted string as you know, contains several characetrs like "yoBGGEV+Zda2v2TEP6a2Jg==". Is that the reason for the updating problem? I find the record with another unique key and try to update, it gives syntax error. However, updating other fields is not a problem. The field size is big enough. What I do, as a workwround is delete that record (that works) and re-create again which is annoying and isnt right.

    Any clues?

    Thank You,
    Charu.

  2. #2
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: Updating an encrypted string

    Are you using a parameterized query? You should be.

    http://builder.com.com/5100-6371_14-6093390.html
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  3. #3
    Join Date
    Mar 2004
    Posts
    223

    Re: Updating an encrypted string

    Thank, please see this. I use :

    strFind = "Update Login SET Password = '" & Trim(pwd.ToString()) & "'" & _
    " where EmployeeID =" + empid

    Password is of size 255. Pwd is the encryopted string here. It doesnt work anyway. Whats wrong in this?

  4. #4
    Join Date
    Feb 2000
    Location
    OH - USA
    Posts
    1,892

    Arrow Re: Updating an encrypted string

    Again:
    Quote Originally Posted by Craig Gemmill
    Are you using a parameterized query? You should be.
    http://builder.com.com/5100-6371_14-6093390.html
    Code:
            Dim strSQL As String = "Update Login SET Password = @password where EmployeeID = @empid"
            Dim sqlCommand As New SqlClient.SqlCommand(strSQL)
            With sqlCommand.Parameters
                .Add(New SqlClient.SqlParameter("@password", Trim(pwd.tostring)))
                .Add(New SqlClient.SqlParameter("@empid", empID))
            End With
    Good Luck,
    Craig - CRG IT Solutions - Microsoft Gold Partner

    -My posts after 08/2015 = .NET 4.x and Visual Studio 2015
    -My posts after 11/2011 = .NET 4.x and Visual Studio 2012
    -My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
    -My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
    -My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
    -My posts before 04/2007 = .NET 1.1/2.0

    *I do not follow all threads, so if you have a secondary question, message me.

  5. #5
    Join Date
    Mar 2004
    Posts
    223

    Re: Updating an encrypted string

    Tried this. It didnt work. Please note pwd is an encrypted string.

    Private Sub UpdatePassword2(ByVal email As String, ByVal empid As String, ByVal pwd As String)
    Dim strFind As String
    strFind = "Update Login SET Password = @Password and EmployeeID =@empid"
    Dim cmd As New Data.OleDb.OleDbCommand(strFind, MyConn)
    cmd.CommandText = strFind
    cmd.Parameters.Add("@Password", Data.OleDb.OleDbType.BSTR).Value = Trim(pwd.ToString())
    cmd.Parameters.Add("@empid", Data.OleDb.OleDbType.BSTR).Value = empid
    cmd.ExecuteNonQuery()
    End Sub

    Throws an exception saying syntax error in UPDATE statement. Its not recognizing something here. Its bcos of the encrypted string like:"yoBGGEV+Zda2v2TEP6a2Jg=="

    Thanks for the reply anyway.

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

Featured