By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Nasty connection String error / encoding.ascii.getstring error

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.