QC20N
asked on
1 character in all words in givenname should be capitalised.
I have a small task that I hope you guys can help me with.
I have a CSV file in the format of:
GivenName,Surname,Init,Dep ,Title
Sometimes givenname is 2 names and the lastname is just 1.
I have done this (see code), but it is tease me.
If there is 1 givenname it is ok, but if there 2 givennames both names are all small.
Hope you can help me.
I have a CSV file in the format of:
GivenName,Surname,Init,Dep
Sometimes givenname is 2 names and the lastname is just 1.
I have done this (see code), but it is tease me.
If there is 1 givenname it is ok, but if there 2 givennames both names are all small.
Hope you can help me.
procedure TFrmMain.Button7Click(Sender: TObject);
var strListOrg, strLineList : TStringlist; I : integer; adComp : IADsContainer; adUser : IADsUser; tmp, givenname, lastname : string;
begin
opendialog1.Filter := 'Comma Delimited (*.csv)|*.CSV';
if opendialog1.Execute then
begin
if opendialog1.FileName <> '' then
begin
strListOrg := TStringlist.Create;
strListOrg.LoadFromFile(OpenDialog1.FileName);
try
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text := 'SELECT sAMAccountName, mail FROM '+ Quotedstr('LDAP://OU=USERS,' + edit2.Text) + ' WHERE objectClass='+ Quotedstr('user') + ' ORDER by CN';
ADOQuery1.Open;
try
for I := 0 to strListOrg.Count - 1 do
begin
strLineList := TStringList.Create;
strLineList.Delimiter := ';';
try
strLineList.DelimitedText := stringreplace(strListOrg[i],' ','_', [rfReplaceAll]);
if not ADOQuery1.Locate('sAMAccountName',copy(edit2.text,10,2)+copy(edit2.Text,4,2)+strLineList[2],[]) then
if not ADOQuery1.Locate('mail', trim(lowercase(stringreplace(strLineList[0],'_',' ',[rfReplaceAll])) + '.' + lowercase(stringreplace(strLineList[1],'_',' ',[rfReplaceAll]))) + '@alfalaval.com',[]) then
begin
tmp := lowercase(trim(stringreplace(strLineList[0],'_',' ',[rfReplaceAll])));
givenname := Uppercase(tmp[1]) + copy(tmp,2,length(tmp));
tmp := lowercase(trim(stringreplace(strLineList[1],'_',' ',[rfReplaceAll])));
lastname := Uppercase(tmp[1]) + copy(tmp,2,length(tmp));
tmp := Tmp ;
end;
finally
strLineList.Free;
end;
end;
finally
ADOQuery1.Close;
end;
finally
strListOrg.Free;
end;
end;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.