请看下面的代码在为ADOConnect对象的WillConnect事件中运行代码
    其中 cnnMain 为TADOConnect
    mCfg 自定义结构,保存系统配置
    cnnMain->ConnectionTimeout = mCfg->ConnecteTimeOut;
    cnnMain->CommandTimeout = mCfg->ConnecteTimeOut;

    AnsiString lstrTemp;
    lstrTemp.sprintf("Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=cmasxp;Data Source=%s",
mCfg->SQLUserPwd,mCfg->SQLUserName,mCfg->ServerName);
    ConnectionString = lstrTemp;
    UserID = mCfg->SQLUserName;
    Password = mCfg->SQLUserPwd;
Initial Catalog=cmasxp 为默认的数据库名与具体的物理文件名无关