--- DriverManager/SQLConnect.c.orig	2007-07-01 22:58:53.000000000 +0200
+++ DriverManager/SQLConnect.c	2007-07-01 22:57:10.000000000 +0200
@@ -3647,6 +3647,8 @@
 
                 return function_return( SQL_HANDLE_DBC, connection, SQL_ERROR );
             }
+			
+			name_length1 = len;
         }
         else
         {
@@ -3688,6 +3690,7 @@
     else
     {
         strcpy( dsn, "DEFAULT" );
+		name_length1 = 8;
     }
 
     /*
@@ -3837,6 +3840,22 @@
 
         return function_return( SQL_HANDLE_DBC, connection, SQL_ERROR );
     }
+	
+	if (name_length2==SQL_NTS) {
+		if (user_name!=(SQLCHAR*)0) {
+			name_length2 = strlen((char*)user_name);
+		} else {
+			name_length2 = 0;
+		}
+	}
+
+	if (name_length3==SQL_NTS) {
+		if (authentication!=(SQLCHAR*)0) {
+			name_length3 = strlen((char*)authentication);
+		} else {
+			name_length3 = 0;
+		}
+	}
 
     if ( CHECK_SQLCONNECT( connection ))
     {
@@ -3855,7 +3874,7 @@
 
         ret_from_connect = SQLCONNECT( connection,
                 connection -> driver_dbc,
-                dsn, SQL_NTS,
+                dsn, name_length1,
                 user_name, name_length2,
                 authentication, name_length3 );
 
@@ -3982,7 +4001,7 @@
 
         ret_from_connect = SQLCONNECTW( connection,
                 connection -> driver_dbc,
-                uc_dsn, SQL_NTS,
+                uc_dsn, name_length1,
                 uc_user, name_length2,
                 uc_auth, name_length3 );
 

