Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:12:48+00:00 2026-06-11T00:12:48+00:00

Okay so i found what was wrong, it was in the sql convert function.

  • 0

Okay so i found what was wrong, it was in the sql convert function. I was converting to varchar(30) when it was supposed to be nvarchar(30). To see the difference. What is the difference between varchar and nvarchar?

I guess this might be a silly question but i can’t seem to be able to remove some sort of space from a string returned by this function. I guess the first real question is why is this function returning a string like this “1 2 3 4 5 6 7 8 9” when we’re saving to the database like this “1234789”. Second question is why something like this

Replace("1 2 3 4 5 6 7 8 9","\p{Zs}","")

or

Replace("1 2 3 4 5 6 7 8 9"," ","")

Is not working, i have a feeling its because of the characters inbetween look like spaces but are not.

My Watch

    Private Shared Function GetEncryptedPmtField(lhID As Integer, accountId As Integer, fieldName As String)
        Dim openKeyCmd = String.Format("OPEN SYMMETRIC KEY somekey DECRYPTION BY PASSWORD = '{0}'",     ConfigurationManager.AppSettings("Somethingsomething"))
        Const closeKeyCmd As String = "CLOSE SYMMETRIC KEY somekey"

        Dim command As New SqlCommand()
        command.Connection = New SqlConnection(ConfigurationManager.ConnectionStrings("Something").ConnectionString)
        command.CommandType = CommandType.Text
        command.CommandText = String.Format("{0} SELECT convert(varchar(30),decryptbykey({1})  FROM  paymentacct WHERE lh_id = @lhid AND id = @id ; {2}", openKeyCmd, fieldName, closeKeyCmd)
        command.Parameters.AddRange({New SqlParameter With {.ParameterName = "lhid", .Value = lhID}, New SqlParameter With {.ParameterName = "id", .Value = accountId}})
        command.Connection.Open()
        Dim baNum = command.ExecuteScalar().ToString()
        command.Connection.Close()
        Return baNum
    End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:12:49+00:00Added an answer on June 11, 2026 at 12:12 am

    Thank you everyone for the help, here is the fix.
    So, the issue was in the type I was converting the encrypted field to. I was using varchar instead of nvarchar.

      SELECT convert(varchar(30),decryptbykey(keyname) FROM  paymentacct
    

    to

     SELECT convert(nvarchar(30),decryptbykey(keyname))  FROM  paymentacct
    

    Note the varchar -> nvarchar change in the convert function

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, Ive searched around and found how this is supposed to be done. For
Okay, I have done a bit of searching online and found this thread, but
Okay, I feel a bit foolish for having to ask this but I guess
Okay everyone, I have found multiple ways of doing this and I have even
okay i have found the way to run a video in a image.... the
Okay so the following line returns null because its path cannot be found: System.IO.FileInfo
Okay, so I have been searching and searching and have not found any help.
Okay this question is very simple: I have a facebook page, and a website.
Okay, this is (probably) a very simple question, but I am afraid I know
Okay I just typed this whole question out and then managed to delete it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.