My best guess is that LogonInfo.Mx_Logon and LogonInfo.Mx_Password didn't have the correct values when strCon was initialized, but they got their values later. I suggest you set strCon to whatever value it has to be after you set LogonInfo.Mx_Logon and LogonInfo.Mx_Password instead of right when you declare it.