VB6 connection string changing

I'm opening a SQL Server 2008 database from VB6

Dim MyCon As ADODB.Connection

Open in new window

When I type the following in the immediate window
? MyCon

I get this
Provider=SQLOLEDB.1;User ID=USERNAME;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=DEV-PC;Use Encryption for Data=False;Tag with column collation when possible=False;

Why is it changing my connectionstring?
Who is Participating?
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
if I remember correctly, it goes to the properties collection:

the database actually selected will be the "Current Catalog" entry,
the server name goes to "Server Name" entry
all that was "removed" went to "Extended properties"
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
the servername and db name are "moved" to other properties of the adodb.connectin object on opening.

and on opening, some properties fetched from the server are "added" to the connection string (for information)
Keep in mind that when you set the connection string, you are not simply setting the value of a variable.  You are actually calling a Property Let function.  The programmer of that object can have more code behind a Property function than just simply setting a variable.  

Here is a contrived example of a VB Class source code:
Private m_Long As Boolean
Private m_StrValue As String
Public Property Let StrValue(Data As String)
    If Len(Data) > 10 Then
        m_Long = True
        m_Long = False
    End If
    m_StrValue = Left$(Data, 10)
End Property
Public Property Get StrValue() As String
    If m_Long Then
        StrValue = m_StrValue & "..."
        StrValue = m_StrValue
    End If
End Property

Open in new window

If the class is named Class1, then you could have some code like the following:
Dim C as new Class1
Dim Str1 as String
Dim Str2 as String
Str1 = "123456789012"
C.StrValue = Str1
Str2 = C.StrValue
If Str1 <> Str2 Then
   MsgBox "They Do Not Match"
End If

Open in new window

The line C.StrValue = Str1 would call Class1.Property Let StrValue.  That routine looks to see if the string is longer than 10 characters, and if so only stores the 1st 10 characters and sets a flag to indicate the string was too long.
The line Str2 = C.StrValue would call Class1.Property Get StrValue.  That routine returns the content of m_StrValue and appends "..." if the flag was set to indicate the original value given was too long.

So if you execute the above code, you will see the message "They Do Not Match" becase Str1 is "123456789012", while Str2 is "1234567890...".
koossaAuthor Commented:
In which properties is the server name and database name stored?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.