边
边城过客
Unregistered / Unconfirmed
GUEST, unregistred user!
现象:如果连接字符串正确,提示成功;如果连接字符串不对,就没出跳出连接失败的提示,在运行到“ADOConnection1.Open;”的时候直接出现:<br>Project Project1.exe raised exception class EOLeException with message '用户'sa'登陆失败。'Process stoped.Use Step or Run to continue. <br><br>源代码如下:<br>begin<br> try<br> try<br> Screen.Cursor := crHourGlass;<br> Button2Click(nil);<br> if ADOConnection1.Connected then ADOConnection1.Close;<br> ADOConnection1.ConnectionString := 'Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=' + strDataBaseName;<br> if Trim(strServerName) <> '' then<br> ADOConnection1.ConnectionString := ADOConnection1.ConnectionString + ';Data Source=' + strServerName;<br> ADOConnection1.ConnectionString := ADOConnection1.ConnectionString + ';Password=' + strPassword + ';User ID=' + strUserName;<br> ADOConnection1.Open;<br> Application.MessageBox('连接成功 ', '提示信息', MB_ICONINFORMATION);<br> ADOConnection1.Close;<br> except<br> Application.MessageBox('连接失败', '提示信息', MB_ICONERROR);<br> end;<br> finally<br> ADOConnection1.Close;<br> Screen.Cursor := crDefault;<br> end;<br>end;