473,396 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Nasty connection String error / encoding.ascii.getstring error

I am creating an connection string at runtime using decryption (crypto
libraries).

i have a very unpridictable error while assinging the generated
connection string to the connection property.

my code is something like this ...

Public Function DbconnStr(ByVal UID As String, ByVal Pwd As String, _
ByVal ServerName As String,
ByVal DbName As String) As StringBuilder

Dim str as stringbuilder
Dim UIDinfo As String =
Convert.ToBase64String(DecryptData.Decrypt(Encodin g.ASCII.GetBytes(UID)))
Dim PWDinfo As String =
Convert.ToBase64String(DecryptData.Decrypt(Encodin g.ASCII.GetBytes(Pwd)))

Str.Append("Server=")
Str.Append(ServerName)
Str.Append(";Database=")
Str.Append(DbName)
Str.Append(";User ID=")
Str.Append(UIDinfo)
Str.Append(";password=")
Str.Append(PWDinfo)
Str.Append(";Trusted_Connection=False")

Catch ex As Exception
Throw New Exception("In WASC " & ex.Message)
End Try
Return Str
End Function
the generated string ... something like
--"Server=GVA21943\SQLSERVER;Database=Northwind; User

ID=WASCuser;password=welcome;Trusted_Connection=Fa lse"

the error is ---Format of the initialization string does not conform
to specification starting at index 61. -- which is always the end of

user ID.

If i hard code the same value i am thru the connection.
Also i noticed an additional char when i find the length of the string
generated for UIDinfo and PWDinfo.
so when i delete the last character generated ... again the connection
is thru at runtime.
But without deleting when i print the connectstring ... i don't find
that character ...its invisible....

pls help me to know y that invisible character (at the end of the
generated string for UIDinfo and PWDinfo) giving me this nasty error.

thanks.
Nov 20 '05 #1
1 4865
James,
What is DecryptData.Decrypt?
pls help me to know y that invisible character (at the end of the
generated string for UIDinfo and PWDinfo) giving me this nasty error.
Are you comfortable that DecryptData.Decrypt or Convert.ToBase64String are
not including a trailing character on the end of the string that is being
returned?

Such as a trailing null char (ChrW(0)) or something?

Or even your input string itself.

Hope this helps
Jay

"james" <ja*******@yahoo.com> wrote in message
news:35**************************@posting.google.c om... I am creating an connection string at runtime using decryption (crypto
libraries).

i have a very unpridictable error while assinging the generated
connection string to the connection property.

my code is something like this ...

Public Function DbconnStr(ByVal UID As String, ByVal Pwd As String, _
ByVal ServerName As String,
ByVal DbName As String) As StringBuilder

Dim str as stringbuilder
Dim UIDinfo As String =
Convert.ToBase64String(DecryptData.Decrypt(Encodin g.ASCII.GetBytes(UID)))
Dim PWDinfo As String =
Convert.ToBase64String(DecryptData.Decrypt(Encodin g.ASCII.GetBytes(Pwd)))

Str.Append("Server=")
Str.Append(ServerName)
Str.Append(";Database=")
Str.Append(DbName)
Str.Append(";User ID=")
Str.Append(UIDinfo)
Str.Append(";password=")
Str.Append(PWDinfo)
Str.Append(";Trusted_Connection=False")

Catch ex As Exception
Throw New Exception("In WASC " & ex.Message)
End Try
Return Str
End Function
the generated string ... something like
--"Server=GVA21943\SQLSERVER;Database=Northwind; User

ID=WASCuser;password=welcome;Trusted_Connection=Fa lse"

the error is ---Format of the initialization string does not conform
to specification starting at index 61. -- which is always the end of

user ID.

If i hard code the same value i am thru the connection.
Also i noticed an additional char when i find the length of the string
generated for UIDinfo and PWDinfo.
so when i delete the last character generated ... again the connection
is thru at runtime.
But without deleting when i print the connectstring ... i don't find
that character ...its invisible....

pls help me to know y that invisible character (at the end of the
generated string for UIDinfo and PWDinfo) giving me this nasty error.

thanks.

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: wkodie | last post by:
I'm having trouble encrypting/decrypting a simple string using the System.Security.Cryptography.TripleDESCryptoServiceProvider, etc... The encryption works, but the decryption does not properly...
2
by: Gary Short | last post by:
Hello group, I was wondering if anyone here could help me with an odd WebClient problem. When I run the following code: WebClient aWebClient = new WebClient(); Byte aBA =...
4
by: Brian Rice | last post by:
I have a socket application that is sending and receiving packets asynchronously. It works great except, when I receive packets that are larger than my receive buffer which then generate several...
2
by: kscdavefl | last post by:
I am using the following code to populate a texst box: private string convertstring(string getLD) { Byte myBytes13 = {13}; string myStr13 = System.Text.Encoding.ASCII.GetString(myBytes13); ...
8
by: KRoy | last post by:
I have a password stored in the Registry encrypted using System.Security.Cryptography DES Algorithm. I supplied it a password and a Initialization Vector. I am trying to decrypt it using the...
1
by: Terrance | last post by:
I'm trying to create a small messenger program that uses the tcpclient and tcplistenter objects. When I start the application and run the thread that fires the tcplistener; once the client sends...
3
by: Sir Psycho | last post by:
Hi, For some reason, when i step over this code, it returns the full byte stream im expecting from the server, however when I let it run with no intervention, it only seems to grab a small chunk...
0
by: id10t error | last post by:
Hello, I am trying to write soem code that will send data to an Oneil printer over our network. I know the printer works and is setup correctly because I can print to it from there software. In...
13
by: Eps | last post by:
Hi there, I believe all strings in .net are unicode by default, I am looking for a way to remove all non ascii characters from a string (or optionally replace them). There is an article on...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.