解决方法
如果您使用的是ADO组件,可以试试这个.
选项1
Uses OleDB,ComObj,ActiveX; function Edit_ADO_ODBC_ConnectionString(ParentHandle: THandle; InitialString: WideString;out NewString: string): Boolean; var DataInit : IDataInitialize; DBPrompt : IDBPromptInitialize; DataSource: IUnknown; InitStr : PWideChar; begin Result := False; DataInit := CreateComObject(CLSID_DataLinks) as IDataInitialize; if InitialString <> '' then DataInit.GetDataSource(nil,CLSCTX_INPROC_SERVER,PWideChar(InitialString),IUnknown,DataSource); DBPrompt := CreateComObject(CLSID_DataLinks) as IDBPromptInitialize; { DBPROMPTOPTIONS_WIZARDSHEET = $1; DBPROMPTOPTIONS_PROPERTYSHEET = $2; DBPROMPTOPTIONS_BROWSEONLY = $8; DBPROMPTOPTIONS_DISABLE_PROVIDER_SELECTION = $10; } if Succeeded(DBPrompt.PromptDataSource(nil,ParentHandle,DBPROMPTOPTIONS_PROPERTYSHEET,nil,DataSource)) then begin InitStr := nil; DataInit.GetInitializationString(DataSource,True,InitStr); NewString := InitStr; Result := True; end; end; Result:=Edit_ADO_ODBC_ConnectionString(0,OldConnectionString,NewString);
选项2
Uses ADODB; PromptDataSource(Self.Handle,InitialString);
选项3
Uses ADODB,AdoConEd; procedure TMainForm.Button2Click(Sender: TObject); Var ADOConnection1 : TADOConnection; begin ADOConnection1:=TADOConnection.Create(Self); EditConnectionString(ADOConnection1); end;
您必须选择“用于ODBC驱动程序的Microsoft OLE DB提供程序”
再见.