Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid connection string attribute when running on NT 4

Status
Not open for further replies.

earlfo

Programmer
Apr 9, 2003
10
US
I have an existing VB 6 application running SQL Server 6.5. After installing a newer version of the application on an NT 4.0 workstation, I get the message listed in the subject, "Invalid connection string attribute". This does not happen from win 2000 or win 98. Any help on this would be reatly appreciated.
 
any code to help those who help you is also appreciated :)
 
The original message I received used this code:
Dim errLoop As Object
Dim strError, strRet As String

On Error GoTo ErrorHandler

Set m_Connection = New ADODB.Connection

strconnect = "Data Source=xxxxxx;Database=XXXX;UID=" & txtUserID.Text & _
";PWD=" & txtPassword.Text
& ";SQL_PACKET_SIZE=4096"

m_Connection.ConnectionString = strconnect
m_Connection.CommandTimeout = 0
m_Connection.Open

Select Case m_Connection.State
Case adStateOpen
Me.Hide
Main

Case adStateClosed
lblFinished.Caption = "Not Connected to xxxxxx"
Case Else
lblFinished.Caption = "Unknown Connection Error"

End Select

I took out some spaces and commented out the packet size and got a new message:

"Changed database context to XXXX"

Where XXXX is the database I defined in the data source.

Dim errLoop As Object
Dim strError, strRet As String

On Error GoTo ErrorHandler

Set m_Connection = New ADODB.Connection

strconnect = "Data Source=xxxxxx;Database=XXXX;UID=" & txtUserID.Text & _
";PWD=" & txtPassword.Text
'& ";SQL_PACKET_SIZE=4096"

m_Connection.ConnectionString = strconnect
m_Connection.CommandTimeout = 0
m_Connection.Open

Select Case m_Connection.State
Case adStateOpen
Me.Hide
Main

Case adStateClosed
lblFinished.Caption = "Not Connected to xxxxxx"
Case Else
lblFinished.Caption = "Unknown Connection Error"

End Select

 
Have you tried installing a newer version of MDAC on the client PC?
 
MDAC was updated. I also tried changing the connection string to include Provider:

strconnect = "Data Source=cavion;Database=CMC3;Provider=MSDASQL;UID=" & _
txtUserID.Text & ";PWD=" & txtPassword.Text
 
MSDASQL is the provider for an ODBC connection. Based on the lack of a DSN in your connection, you probably want PROVIDER=SQLOLEDB.
 
I tried SQLOLDB first. I am using ODBC, 'Data Source' Defines the ODBC connection.
 
Code:
Data Source
specifies the server name. Use
Code:
DSN
for your ODBC DSN.
 
Better yet, use this example for your connection string:
Code:
[URL unfurl="true"]http://www.able-consulting.com/MDAC/ADO/Connection/OLEDB_Providers.htm#OLEDBProviderForODBCDatabases[/URL]
 
I changed the connection string to:
strconnect = "DSN=cavion;Database=CMC3;Provider=SQLOLEDB;UID=" & _
txtUserID.Text & ";PWD=" & txtPassword.Text


And got this error:
1)
Invalid connection string attribute
(Source: Microsoft OLE DB Provider for SQL Server)
(SQL State: 01S00)
2)
SQL Server Does not exist or access denied

When I use 'Data Source' instead of 'DSN' I can connect on my development PC.
 
Here is how I connect to an ODBC

Set g_Cn_DB = New ADODB.Connection
g_Cn_DB.CursorLocation = adUseClient
g_Cn_DB.Mode = adModeReadWrite
g_Cn_DB.Provider = "MSDASQL.1"
g_Cn_DB.Properties("Persist Security Info") = False
g_Cn_DB.Properties("User ID") = "??"
g_Cn_DB.Properties("Data Source") = "GPSS"
g_Cn_DB.CommandTimeout = 0
g_Cn_DB.Open

GPSS = the name of my ODBC.

Look at the provider (it is different than yours)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top