Help needed - Can't get TADOQuery to select and display unicode data.

Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  Unicode data is displayed as ?.  I have a similar code using Dbexpress TSQLQuery that works ok, so i know unicode can display on my PC.  Spent two days searching for the solution and tweaking my code (changing to widestring) but to no avail.  Hope someone can help me.  Apppreciate.  :)

Code as below.  The data comes out of 's' string.  Unicode comes out as question marks (?).
Please also note my comments beginning with //**.  I've  tried the following as well, but to no avail:

s:widestring;  
s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value; 



procedure GetSQLADO(myQry:TADOQuery);    
     var

          sFail:string;
          sNoResult:string;
          s3:widestring;

      //    s:widestring;      
      //** i also tried s:widestring.

     begin

          sFail:=tmpstr;
          sNoResult:=s;
          try myQry.close;except end;
          myQry.sql.clear;
          myQry.sql.add(strContent);
          try
               myQry.prepared:=true;
               if boolSelect  then

               begin
                    myQry.open;
                    myQry.first;
                    if myQry.eof
                    then
                    begin // no reuslt reutrn
                         sMsg:=sNoResult;
                         try myqry.close;except end;
                         exit;
                    end;
                    ii:=pos('[',sMsg);
                    jj:=pos(']',sMsg);
                    while ii<jj do
                    begin
                         sRepeat:='';
                         myQry.First;
                         while not myQry.eof do
                         begin
                              tmpstr:=copy(sMsg,ii+1,jj-ii-1);
                              i:=pos('{',tmpstr);
                              j:=pos('}',tmpstr);
                              while i<j do
                              begin
                                   try
                                        begin
                                             s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');

                                             s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).asstring;
                                     
                                     //      s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value;    
                          //** used this when i set s:widestring as above.
                                                  


                                        end;
                                   except
                                        on e:exception do
                                        begin
                                             displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (4):'+myQry.sql.Text+' Exception: '+e.message);
                                             displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (4):'+s3);
                                             s:='ERROR FIELD';
                                        end;
                                   end;
                                   sRepeat:=sRepeat+copy(tmpstr,1,i-1)+s;
                                   tmpstr:=copy(tmpstr,j+1,length(tmpstr)-j);
                                   i:=pos('{',tmpstr);
                                   j:=pos('}',tmpstr);
                              end; // while i<j
                              sRepeat:=sRepeat+tmpstr;
                              if not boolMultiRec then
                              begin break end;
                              myQry.Next;
                         end; // while not eof
                         delete(sMsg,ii,jj-ii+1);
                         insert(sRepeat,sMsg,ii);
                         ii:=pos('[',sMsg);
                         jj:=pos(']',sMsg);
                    end; // while ii<jj

                    i:=pos('{',sMsg);
                    j:=pos('}',sMsg);

                    while i<j do
                    begin
                         sRepeat:='';
                         myQry.first;
                         while not myQry.eof do
                         begin
                              try
                                   begin
                                        s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
                                        s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).asstring;
                             //      s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).value;


                                   end;
                              except
                                   on e:exception do
                                   begin
                                        displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (5):'+myQry.sql.Text+' Exception: '+e.message);
                                        displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (5):'+s3);
                                        s:='ERROR FIELD';
                                   end;
                              end;
                              if sRepeat=''
                              then
                              begin sRepeat:=s end
                              else
                              begin sRepeat:=sRepeat+','+s end;
                              if not boolMultiRec then
                              begin break end;
                              myQry.next;
                         end ;// while not eof

                         delete(sMsg,i,j-i+1);
                         insert(sRepeat,sMsg,i);
                         i:=pos('{',sMsg);
                         j:=pos('}',sMsg);
                    end;// while i<j do
                    i:=pos('\n',sMsg);
                    while i>0 do
                    begin
                         sMsg:=copy(sMsg,1,i-1)+chr(13)+chr(10)+copy(sMsg,i+2,length(sMsg)-i);
                         i:=pos('\n',sMsg);
                    end;
               end//if boolselect
               else
               begin
                    myQry.ExecSQL;
                    if myQry.RowsAffected<1 then
                    begin sMsg:=sFail end;
               end;
          except
               on e:Exception do
               begin
                    sMsg:=sFail;
                    displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL query (6):'+myQry.sql.Text+' Exception: '+e.message);

               end;

          end; //try
     end;

Edited by: joshua lim on Oct 6, 2008 7:24 AM
0
joshua
10/6/2008 2:24:39 PM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

9 Replies
640 Views

Similar Articles

[PageSpeed] 55

> {quote:title=joshua lim wrote:}{quote}
> Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  Unicode data is displayed as ?.  I have a similar code using Dbexpress TSQLQuery that works ok, so i know unicode can display on my PC.  Spent two days searching for the solution and tweaking my code (changing to widestring) but to no avail.  Hope someone can help me.  Apppreciate.  :)
> 
> Code as below.  The data comes out of 's' string.  Unicode comes out as question marks (?).
> Please also note my comments beginning with //**.  I've  tried the following as well, but to no avail:
> 
> s:widestring;  
> s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value; 
> 
> 
> 
> procedure GetSQLADO(myQry:TADOQuery);    
>      var
> 
>           sFail:string;
>           sNoResult:string;
>           s3:widestring;
> 
>       //    s:widestring;      
>       //** i also tried s:widestring.
> 
>      begin
> 
>           sFail:=tmpstr;
>           sNoResult:=s;
>           try myQry.close;except end;
>           myQry.sql.clear;
>           myQry.sql.add(strContent);
>           try
>                myQry.prepared:=true;
>                if boolSelect  then
> 
>                begin
>                     myQry.open;
>                     myQry.first;
>                     if myQry.eof
>                     then
>                     begin // no reuslt reutrn
>                          sMsg:=sNoResult;
>                          try myqry.close;except end;
>                          exit;
>                     end;
>                     ii:=pos('[',sMsg);
>                     jj:=pos(']',sMsg);
>                     while ii<jj do
>                     begin
>                          sRepeat:='';
>                          myQry.First;
>                          while not myQry.eof do
>                          begin
>                               tmpstr:=copy(sMsg,ii+1,jj-ii-1);
>                               i:=pos('{',tmpstr);
>                               j:=pos('}',tmpstr);
>                               while i<j do
>                               begin
>                                    try
>                                         begin
>                                              s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
> 
>                                              s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).asstring;
>                                      
>                                      //      s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value;    
>                           //** used this when i set s:widestring as above.
>                                                   
> 
> 
>                                         end;
>                                    except
>                                         on e:exception do
>                                         begin
>                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (4):'+myQry.sql.Text+' Exception: '+e.message);
>                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (4):'+s3);
>                                              s:='ERROR FIELD';
>                                         end;
>                                    end;
>                                    sRepeat:=sRepeat+copy(tmpstr,1,i-1)+s;
>                                    tmpstr:=copy(tmpstr,j+1,length(tmpstr)-j);
>                                    i:=pos('{',tmpstr);
>                                    j:=pos('}',tmpstr);
>                               end; // while i<j
>                               sRepeat:=sRepeat+tmpstr;
>                               if not boolMultiRec then
>                               begin break end;
>                               myQry.Next;
>                          end; // while not eof
>                          delete(sMsg,ii,jj-ii+1);
>                          insert(sRepeat,sMsg,ii);
>                          ii:=pos('[',sMsg);
>                          jj:=pos(']',sMsg);
>                     end; // while ii<jj
> 
>                     i:=pos('{',sMsg);
>                     j:=pos('}',sMsg);
> 
>                     while i<j do
>                     begin
>                          sRepeat:='';
>                          myQry.first;
>                          while not myQry.eof do
>                          begin
>                               try
>                                    begin
>                                         s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
>                                         s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).asstring;
>                              //      s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).value;
> 
> 
>                                    end;
>                               except
>                                    on e:exception do
>                                    begin
>                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (5):'+myQry.sql.Text+' Exception: '+e.message);
>                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (5):'+s3);
>                                         s:='ERROR FIELD';
>                                    end;
>                               end;
>                               if sRepeat=''
>                               then
>                               begin sRepeat:=s end
>                               else
>                               begin sRepeat:=sRepeat+','+s end;
>                               if not boolMultiRec then
>                               begin break end;
>                               myQry.next;
>                          end ;// while not eof
> 
>                          delete(sMsg,i,j-i+1);
>                          insert(sRepeat,sMsg,i);
>                          i:=pos('{',sMsg);
>                          j:=pos('}',sMsg);
>                     end;// while i<j do
>                     i:=pos('\n',sMsg);
>                     while i>0 do
>                     begin
>                          sMsg:=copy(sMsg,1,i-1)+chr(13)+chr(10)+copy(sMsg,i+2,length(sMsg)-i);
>                          i:=pos('\n',sMsg);
>                     end;
>                end//if boolselect
>                else
>                begin
>                     myQry.ExecSQL;
>                     if myQry.RowsAffected<1 then
>                     begin sMsg:=sFail end;
>                end;
>           except
>                on e:Exception do
>                begin
>                     sMsg:=sFail;
>                     displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL query (6):'+myQry.sql.Text+' Exception: '+e.message);
> 
>                end;
> 
>           end; //try
>      end;
> 
> Edited by: joshua lim on Oct 6, 2008 7:24 AM
0
Brian
10/7/2008 1:55:31 AM
If it is coming out as ? characters you are using controls or procedures that don't support unicode.
There isn't much support in Delpi 7 to support unicode
do a Google search on "Delphi 7 Unicode"


> {quote:title=joshua lim wrote:}{quote}
> Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  Unicode data is displayed as ?.  I have a similar code using Dbexpress TSQLQuery that works ok, so i know unicode can display on my PC.  Spent two days searching for the solution and tweaking my code (changing to widestring) but to no avail.  Hope someone can help me.  Apppreciate.  :)
> 
> Code as below.  The data comes out of 's' string.  Unicode comes out as question marks (?).
> Please also note my comments beginning with //**.  I've  tried the following as well, but to no avail:
> 
> s:widestring;  
> s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value; 
> 
> 
> 
> procedure GetSQLADO(myQry:TADOQuery);    
>      var
> 
>           sFail:string;
>           sNoResult:string;
>           s3:widestring;
> 
>       //    s:widestring;      
>       //** i also tried s:widestring.
> 
>      begin
> 
>           sFail:=tmpstr;
>           sNoResult:=s;
>           try myQry.close;except end;
>           myQry.sql.clear;
>           myQry.sql.add(strContent);
>           try
>                myQry.prepared:=true;
>                if boolSelect  then
> 
>                begin
>                     myQry.open;
>                     myQry.first;
>                     if myQry.eof
>                     then
>                     begin // no reuslt reutrn
>                          sMsg:=sNoResult;
>                          try myqry.close;except end;
>                          exit;
>                     end;
>                     ii:=pos('[',sMsg);
>                     jj:=pos(']',sMsg);
>                     while ii<jj do
>                     begin
>                          sRepeat:='';
>                          myQry.First;
>                          while not myQry.eof do
>                          begin
>                               tmpstr:=copy(sMsg,ii+1,jj-ii-1);
>                               i:=pos('{',tmpstr);
>                               j:=pos('}',tmpstr);
>                               while i<j do
>                               begin
>                                    try
>                                         begin
>                                              s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
> 
>                                              s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).asstring;
>                                      
>                                      //      s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value;    
>                           //** used this when i set s:widestring as above.
>                                                   
> 
> 
>                                         end;
>                                    except
>                                         on e:exception do
>                                         begin
>                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (4):'+myQry.sql.Text+' Exception: '+e.message);
>                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (4):'+s3);
>                                              s:='ERROR FIELD';
>                                         end;
>                                    end;
>                                    sRepeat:=sRepeat+copy(tmpstr,1,i-1)+s;
>                                    tmpstr:=copy(tmpstr,j+1,length(tmpstr)-j);
>                                    i:=pos('{',tmpstr);
>                                    j:=pos('}',tmpstr);
>                               end; // while i<j
>                               sRepeat:=sRepeat+tmpstr;
>                               if not boolMultiRec then
>                               begin break end;
>                               myQry.Next;
>                          end; // while not eof
>                          delete(sMsg,ii,jj-ii+1);
>                          insert(sRepeat,sMsg,ii);
>                          ii:=pos('[',sMsg);
>                          jj:=pos(']',sMsg);
>                     end; // while ii<jj
> 
>                     i:=pos('{',sMsg);
>                     j:=pos('}',sMsg);
> 
>                     while i<j do
>                     begin
>                          sRepeat:='';
>                          myQry.first;
>                          while not myQry.eof do
>                          begin
>                               try
>                                    begin
>                                         s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
>                                         s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).asstring;
>                              //      s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).value;
> 
> 
>                                    end;
>                               except
>                                    on e:exception do
>                                    begin
>                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (5):'+myQry.sql.Text+' Exception: '+e.message);
>                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (5):'+s3);
>                                         s:='ERROR FIELD';
>                                    end;
>                               end;
>                               if sRepeat=''
>                               then
>                               begin sRepeat:=s end
>                               else
>                               begin sRepeat:=sRepeat+','+s end;
>                               if not boolMultiRec then
>                               begin break end;
>                               myQry.next;
>                          end ;// while not eof
> 
>                          delete(sMsg,i,j-i+1);
>                          insert(sRepeat,sMsg,i);
>                          i:=pos('{',sMsg);
>                          j:=pos('}',sMsg);
>                     end;// while i<j do
>                     i:=pos('\n',sMsg);
>                     while i>0 do
>                     begin
>                          sMsg:=copy(sMsg,1,i-1)+chr(13)+chr(10)+copy(sMsg,i+2,length(sMsg)-i);
>                          i:=pos('\n',sMsg);
>                     end;
>                end//if boolselect
>                else
>                begin
>                     myQry.ExecSQL;
>                     if myQry.RowsAffected<1 then
>                     begin sMsg:=sFail end;
>                end;
>           except
>                on e:Exception do
>                begin
>                     sMsg:=sFail;
>                     displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL query (6):'+myQry.sql.Text+' Exception: '+e.message);
> 
>                end;
> 
>           end; //try
>      end;
> 
> Edited by: joshua lim on Oct 6, 2008 7:24 AM
0
Brian
10/7/2008 1:58:56 AM
joshua lim wrote:

> i don't think i'm using any controls,

You must be using one or more data aware controls, for
example a DBGrid, on your form or you would not be able to
see the data returned by the query. The Delphi 7 data aware
controls do not support Unicode.

-- 
Bill Todd (TeamB)
0
Bill
10/7/2008 1:58:08 PM
Thanks, i don't think i'm using any controls, it's all TADOQuery.  Also, i got a similar procedure using dbexpress TSQLQuery that works ok with unicode using the same database and data.



> {quote:title=Brian Bushay wrote:}{quote}
> If it is coming out as ? characters you are using controls or procedures that don't support unicode.
> There isn't much support in Delpi 7 to support unicode
> do a Google search on "Delphi 7 Unicode"
> 
> 
> > {quote:title=joshua lim wrote:}{quote}
> > Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  Unicode data is displayed as ?.  I have a similar code using Dbexpress TSQLQuery that works ok, so i know unicode can display on my PC.  Spent two days searching for the solution and tweaking my code (changing to widestring) but to no avail.  Hope someone can help me.  Apppreciate.  :)
> > 
> > Code as below.  The data comes out of 's' string.  Unicode comes out as question marks (?).
> > Please also note my comments beginning with //**.  I've  tried the following as well, but to no avail:
> > 
> > s:widestring;  
> > s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value; 
> > 
> > 
> > 
> > procedure GetSQLADO(myQry:TADOQuery);    
> >      var
> > 
> >           sFail:string;
> >           sNoResult:string;
> >           s3:widestring;
> > 
> >       //    s:widestring;      
> >       //** i also tried s:widestring.
> > 
> >      begin
> > 
> >           sFail:=tmpstr;
> >           sNoResult:=s;
> >           try myQry.close;except end;
> >           myQry.sql.clear;
> >           myQry.sql.add(strContent);
> >           try
> >                myQry.prepared:=true;
> >                if boolSelect  then
> > 
> >                begin
> >                     myQry.open;
> >                     myQry.first;
> >                     if myQry.eof
> >                     then
> >                     begin // no reuslt reutrn
> >                          sMsg:=sNoResult;
> >                          try myqry.close;except end;
> >                          exit;
> >                     end;
> >                     ii:=pos('[',sMsg);
> >                     jj:=pos(']',sMsg);
> >                     while ii<jj do
> >                     begin
> >                          sRepeat:='';
> >                          myQry.First;
> >                          while not myQry.eof do
> >                          begin
> >                               tmpstr:=copy(sMsg,ii+1,jj-ii-1);
> >                               i:=pos('{',tmpstr);
> >                               j:=pos('}',tmpstr);
> >                               while i<j do
> >                               begin
> >                                    try
> >                                         begin
> >                                              s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
> > 
> >                                              s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).asstring;
> >                                      
> >                                      //      s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value;    
> >                           //** used this when i set s:widestring as above.
> >                                                   
> > 
> > 
> >                                         end;
> >                                    except
> >                                         on e:exception do
> >                                         begin
> >                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (4):'+myQry.sql.Text+' Exception: '+e.message);
> >                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (4):'+s3);
> >                                              s:='ERROR FIELD';
> >                                         end;
> >                                    end;
> >                                    sRepeat:=sRepeat+copy(tmpstr,1,i-1)+s;
> >                                    tmpstr:=copy(tmpstr,j+1,length(tmpstr)-j);
> >                                    i:=pos('{',tmpstr);
> >                                    j:=pos('}',tmpstr);
> >                               end; // while i<j
> >                               sRepeat:=sRepeat+tmpstr;
> >                               if not boolMultiRec then
> >                               begin break end;
> >                               myQry.Next;
> >                          end; // while not eof
> >                          delete(sMsg,ii,jj-ii+1);
> >                          insert(sRepeat,sMsg,ii);
> >                          ii:=pos('[',sMsg);
> >                          jj:=pos(']',sMsg);
> >                     end; // while ii<jj
> > 
> >                     i:=pos('{',sMsg);
> >                     j:=pos('}',sMsg);
> > 
> >                     while i<j do
> >                     begin
> >                          sRepeat:='';
> >                          myQry.first;
> >                          while not myQry.eof do
> >                          begin
> >                               try
> >                                    begin
> >                                         s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
> >                                         s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).asstring;
> >                              //      s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).value;
> > 
> > 
> >                                    end;
> >                               except
> >                                    on e:exception do
> >                                    begin
> >                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (5):'+myQry.sql.Text+' Exception: '+e.message);
> >                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (5):'+s3);
> >                                         s:='ERROR FIELD';
> >                                    end;
> >                               end;
> >                               if sRepeat=''
> >                               then
> >                               begin sRepeat:=s end
> >                               else
> >                               begin sRepeat:=sRepeat+','+s end;
> >                               if not boolMultiRec then
> >                               begin break end;
> >                               myQry.next;
> >                          end ;// while not eof
> > 
> >                          delete(sMsg,i,j-i+1);
> >                          insert(sRepeat,sMsg,i);
> >                          i:=pos('{',sMsg);
> >                          j:=pos('}',sMsg);
> >                     end;// while i<j do
> >                     i:=pos('\n',sMsg);
> >                     while i>0 do
> >                     begin
> >                          sMsg:=copy(sMsg,1,i-1)+chr(13)+chr(10)+copy(sMsg,i+2,length(sMsg)-i);
> >                          i:=pos('\n',sMsg);
> >                     end;
> >                end//if boolselect
> >                else
> >                begin
> >                     myQry.ExecSQL;
> >                     if myQry.RowsAffected<1 then
> >                     begin sMsg:=sFail end;
> >                end;
> >           except
> >                on e:Exception do
> >                begin
> >                     sMsg:=sFail;
> >                     displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL query (6):'+myQry.sql.Text+' Exception: '+e.message);
> > 
> >                end;
> > 
> >           end; //try
> >      end;
> > 
> > Edited by: joshua lim on Oct 6, 2008 7:24 AM

Edited by: Brian Bushay on Oct 7, 2008 7:46 PM

Edited by: Brian Bushay on Oct 7, 2008 7:52 PM
0
joshua
10/8/2008 2:52:43 AM
I  am not following your code to see how you are displaying the value

s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).asstring;
This line will asign a string value (not unicode) to S because that is what asString does

 s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value;
This line will assing a Widestring to S if that is what the field holds.





> Thanks, i don't think i'm using any controls, it's all TADOQuery.  Also, i got a similar procedure using dbexpress TSQLQuery that works ok with unicode using the same database and data.
> 
> 
> 
> > {quote:title=Brian Bushay wrote:}{quote}
> > If it is coming out as ? characters you are using controls or procedures that don't support unicode.
> > There isn't much support in Delpi 7 to support unicode
> > do a Google search on "Delphi 7 Unicode"
> > 
> > 
> > > {quote:title=joshua lim wrote:}{quote}
> > > Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  Unicode data is displayed as ?.  I have a similar code using Dbexpress TSQLQuery that works ok, so i know unicode can display on my PC.  Spent two days searching for the solution and tweaking my code (changing to widestring) but to no avail.  Hope someone can help me.  Apppreciate.  :)
> > > 
> > > Code as below.  The data comes out of 's' string.  Unicode comes out as question marks (?).
> > > Please also note my comments beginning with //**.  I've  tried the following as well, but to no avail:
> > > 
> > > s:widestring;  
> > > s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value; 
> > > 
> > > 
> > > 
> > > procedure GetSQLADO(myQry:TADOQuery);    
> > >      var
> > > 
> > >           sFail:string;
> > >           sNoResult:string;
> > >           s3:widestring;
> > > 
> > >       //    s:widestring;      
> > >       //** i also tried s:widestring.
> > > 
> > >      begin
> > > 
> > >           sFail:=tmpstr;
> > >           sNoResult:=s;
> > >           try myQry.close;except end;
> > >           myQry.sql.clear;
> > >           myQry.sql.add(strContent);
> > >           try
> > >                myQry.prepared:=true;
> > >                if boolSelect  then
> > > 
> > >                begin
> > >                     myQry.open;
> > >                     myQry.first;
> > >                     if myQry.eof
> > >                     then
> > >                     begin // no reuslt reutrn
> > >                          sMsg:=sNoResult;
> > >                          try myqry.close;except end;
> > >                          exit;
> > >                     end;
> > >                     ii:=pos('[',sMsg);
> > >                     jj:=pos(']',sMsg);
> > >                     while ii<jj do
> > >                     begin
> > >                          sRepeat:='';
> > >                          myQry.First;
> > >                          while not myQry.eof do
> > >                          begin
> > >                               tmpstr:=copy(sMsg,ii+1,jj-ii-1);
> > >                               i:=pos('{',tmpstr);
> > >                               j:=pos('}',tmpstr);
> > >                               while i<j do
> > >                               begin
> > >                                    try
> > >                                         begin
> > >                                              s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
> > > 
> > >                                              s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).asstring;
> > >                                      
> > >                                      //      s:=myQry.fieldbyname(copy(tmpstr,i+1,j-i-1)).value;    
> > >                           //** used this when i set s:widestring as above.
> > >                                                   
> > > 
> > > 
> > >                                         end;
> > >                                    except
> > >                                         on e:exception do
> > >                                         begin
> > >                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (4):'+myQry.sql.Text+' Exception: '+e.message);
> > >                                              displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (4):'+s3);
> > >                                              s:='ERROR FIELD';
> > >                                         end;
> > >                                    end;
> > >                                    sRepeat:=sRepeat+copy(tmpstr,1,i-1)+s;
> > >                                    tmpstr:=copy(tmpstr,j+1,length(tmpstr)-j);
> > >                                    i:=pos('{',tmpstr);
> > >                                    j:=pos('}',tmpstr);
> > >                               end; // while i<j
> > >                               sRepeat:=sRepeat+tmpstr;
> > >                               if not boolMultiRec then
> > >                               begin break end;
> > >                               myQry.Next;
> > >                          end; // while not eof
> > >                          delete(sMsg,ii,jj-ii+1);
> > >                          insert(sRepeat,sMsg,ii);
> > >                          ii:=pos('[',sMsg);
> > >                          jj:=pos(']',sMsg);
> > >                     end; // while ii<jj
> > > 
> > >                     i:=pos('{',sMsg);
> > >                     j:=pos('}',sMsg);
> > > 
> > >                     while i<j do
> > >                     begin
> > >                          sRepeat:='';
> > >                          myQry.first;
> > >                          while not myQry.eof do
> > >                          begin
> > >                               try
> > >                                    begin
> > >                                         s3:=myQry.Recordset.GetString(2, 1, #9, #13#0, '<NULL>');
> > >                                         s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).asstring;
> > >                              //      s:=myQry.fieldbyname(copy(sMsg,i+1,j-i-1)).value;
> > > 
> > > 
> > >                                    end;
> > >                               except
> > >                                    on e:exception do
> > >                                    begin
> > >                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL Query via ADO (5):'+myQry.sql.Text+' Exception: '+e.message);
> > >                                         displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'Display Record Set for Debugging Purpose (5):'+s3);
> > >                                         s:='ERROR FIELD';
> > >                                    end;
> > >                               end;
> > >                               if sRepeat=''
> > >                               then
> > >                               begin sRepeat:=s end
> > >                               else
> > >                               begin sRepeat:=sRepeat+','+s end;
> > >                               if not boolMultiRec then
> > >                               begin break end;
> > >                               myQry.next;
> > >                          end ;// while not eof
> > > 
> > >                          delete(sMsg,i,j-i+1);
> > >                          insert(sRepeat,sMsg,i);
> > >                          i:=pos('{',sMsg);
> > >                          j:=pos('}',sMsg);
> > >                     end;// while i<j do
> > >                     i:=pos('\n',sMsg);
> > >                     while i>0 do
> > >                     begin
> > >                          sMsg:=copy(sMsg,1,i-1)+chr(13)+chr(10)+copy(sMsg,i+2,length(sMsg)-i);
> > >                          i:=pos('\n',sMsg);
> > >                     end;
> > >                end//if boolselect
> > >                else
> > >                begin
> > >                     myQry.ExecSQL;
> > >                     if myQry.RowsAffected<1 then
> > >                     begin sMsg:=sFail end;
> > >                end;
> > >           except
> > >                on e:Exception do
> > >                begin
> > >                     sMsg:=sFail;
> > >                     displayline('Keyword'#9+Commmethod+#9+'SEQNO:'+SeqNo1+#9+'[ERROR] SQL query (6):'+myQry.sql.Text+' Exception: '+e.message);
> > > 
> > >                end;
> > > 
> > >           end; //try
> > >      end;
> > > 
> > > Edited by: joshua lim on Oct 6, 2008 7:24 AM
> 
> Edited by: Brian Bushay on Oct 7, 2008 7:46 PM
> 
> Edited by: Brian Bushay on Oct 7, 2008 7:52 PM
0
Brian
10/8/2008 2:56:13 AM
Thanks Bill.  Not sure what i did (maybe it's the PC), the code as it is now can support unicode, but some characters still cause an exception.  I suspect it is something to do with Window.





> {quote:title=Bill Todd wrote:}{quote}
> joshua lim wrote:
> 
> > i don't think i'm using any controls,
> 
> You must be using one or more data aware controls, for
> example a DBGrid, on your form or you would not be able to
> see the data returned by the query. The Delphi 7 data aware
> controls do not support Unicode.
> 
> -- 
> Bill Todd (TeamB)
0
joshua
10/8/2008 8:18:27 AM
joshua lim wrote:

> I suspect it is something to do with Window.

More likely it is Delphi 7. D7 did not support Unicode. One
of the major changes in Delphi 2009 is full Unicode support.

-- 
Bill Todd (TeamB)
0
Bill
10/8/2008 3:08:28 PM
> {quote:title=joshua lim wrote:}{quote}
> Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  

I had this same problem with Oracle + ADO. Just to clarify:

- Your data, in the database, is really unicode? Or they are ansistrings stored in unicode fields?
- Can you open the ADOQuery and get, for instance, FieldByName('Field1').AsString?

To fix things in an Oracle DB, I changed field mapping inside ADODB.pas, from WideString to String. In this case, the data stored in the DB will be converted to AnsiString implicitily and you will not have to deal with Unicode.

Regards
0
Alexandre
11/5/2008 8:47:48 AM
Thanks everyone for your help.

I managed to solve the problem by reconfiguring the language settings (to code page 950 language) in regional options and rebooting the pc a few times.  The issue is not with D7 or ADO but Windows.


> {quote:title=Alexandre Machado wrote:}{quote}
> > {quote:title=joshua lim wrote:}{quote}
> > Hi, i'm having problems trying to get TADOQuery (D7) to select unicode data.  
> 
> I had this same problem with Oracle + ADO. Just to clarify:
> 
> - Your data, in the database, is really unicode? Or they are ansistrings stored in unicode fields?

The data is in Windows page code 950.
0
joshua
11/5/2008 5:52:36 PM
Reply:

Similar Artilces:

need help with query that gets acc that didn't print to select locations
I need help with a query to find acc_itn's that haven't printed to one of a selection of printers. We have Sybase 12.5 on AIX. The following quey works in MS Access, but I can't get it to work in Sybase. Can anyone help me with syntax here? THanks very much! SELECT DISTINCT A.acc_itn FROM temp_print_tbl AS A LEFT JOIN [SELECT DISTINCT acc_itn FROM temp_print_tbl WHERE doc_mne in ('DSCBT1', 'AP5BT1', 'AP5BT2', 'AP5BT3', 'CCUBT1', 'CCUBT2', 'CCUBT3', 'CI7BT1', 'CI7BT2', 'CI7BT3')]...

couldn't add data to database and could't display the data from datagrid.
I have one page which has two textbox, one button and some display database data from one datagrid. I want to fill in two textbox, then click the button. adding data intextbox to database. and display data from datagrid.my question is I couldn't add data to database and could'tdisplay the data from datagrid. I don't know if my code has problem. my code Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load             Dim con As New SqlConnection(ConfigurationSettings.GetConfig("PCRMAppS...

superreview requested: [Bug 269318] TAB doesn't start from selection text after mouse click : [Attachment 166255] If element gets focused, move selection to focus if focus isn't already inside the s
Aaron Leventhal <aaronleventhal@moonset.net> has asked neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> for superreview: Bug 269318: TAB doesn't start from selection text after mouse click https://bugzilla.mozilla.org/show_bug.cgi?id=269318 Attachment 166255: If element gets focused, move selection to focus if focus isn't already inside the selection. mLastFocusedWith is no longer needed for making tab not move relative to selection after a mouse click https://bugzilla.mozilla.org/attachment.cgi?id=166255&action=edit ...

superreview granted: [Bug 269318] TAB doesn't start from selection text after mouse click : [Attachment 166255] If element gets focused, move selection to focus if focus isn't already inside the sel
neil@parkwaycc.co.uk <neil.parkwaycc.co.uk@myrealbox.com> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 269318: TAB doesn't start from selection text after mouse click https://bugzilla.mozilla.org/show_bug.cgi?id=269318 Attachment 166255: If element gets focused, move selection to focus if focus isn't already inside the selection. mLastFocusedWith is no longer needed for making tab not move relative to selection after a mouse click https://bugzilla.mozilla.org/attachment.cgi?id=166255&action=edit ------- Addition...

Need help with Select Permission denied on object 'abc', database '123', schema 'dbo'
  I am running a C# asp.met application which most of the application is running ok but several of my aspx. pages are giving me this error. I am currentyly running MS-SQL 2005 Dev ed. using VS.net 2005. I have turned on access in role to everything and still am getting this error. can someone help me please? Check what sql login you are using to connect to the SQL Server and to what database user is the login mapped to. If you open the SQL Server Management Studio -> Object Explorer-> [connect to the server]-> expand Security->Logins-> right-click the login you are usi...

DropDownList won't insert data into table that's getting the data from
 The title pretty much says it all. All other rows get populated in the table during insert but Owner_id & Title_id which are foreign keys (owner_id is a FK in the same table (is it possible to do something like that?).Don't know where the problem is so hope you have the answers (and please, post simple answers (not sure i can comprehend the complicated ones).Here's the code: 1 <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" Title="nevermind" %> 2 3 <script runat="server"> 4 5 Protected...

HELP ! data won't display on HTML but does on preview
Hello, I've written a stored procedure to get some data for my HTMLDW. When I display the HTMLDW in my browser, some fields are empty. But when I run my procedure on the database (Sybase), the fields are not empty. And when I test my datawindow in Datawindowbuilder, he also shows the content of the fields. And when I do a HTML-preview in Datawindowbuilder, I also see the data. My retreivalarguments are allways the same. The fields are visible. I also tried to enlarged the field and the lettertype. Does anybody know what's wrong ???? -- Gorik Francois Dolmen Co...

Gridview to display all data if a parameter isn't selected
I'm trying to display all data from a table if a value for a dropdown box is not selected.When I go to this page I will get the results for the first dropdown box item. Dropdown is populated from the same table listing distinct departments. I tried to add an item to the dropdown list and mark it as Selected so that no department was given but it didnt work. Using ASP.NET 2.0/VB <asp:dropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="AccessDataSource2"DataTextField="department" DataValueField="department"> <asp:AccessDataSource ID="AccessDataSource1" r...

Desprately need help getting selected data from dropdown list
hi I have inserted a drop down list in the create user wizard steps and I am trying to store the selected value in my table. The drop down list has two items business and private and is called Listing. In the vb code I have tried to get the selected value to a string called category as shown below: Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUserDim UserNameTextBox As TextBox = DirectCast(CreateUserWizardStep2.ContentTemplateContainer.FindControl("UserName"), TextBox) Dim DataSource As SqlD...

superreview granted: [Bug 300779] Support multiple selection for xul:tree : [Attachment 190476] Expose via a11y events. We don't need DOMItemSelected after all, they aren't fired for tree. We'll go
Robert O'Callahan (Novell) <roc@ocallahan.org> has granted Aaron Leventhal <aaronleventhal@moonset.net>'s request for superreview: Bug 300779: Support multiple selection for xul:tree https://bugzilla.mozilla.org/show_bug.cgi?id=300779 Attachment 190476: Expose via a11y events. We don't need DOMItemSelected after all, they aren't fired for tree. We'll go off of "select" DOM events later for the add/remove a11y events. https://bugzilla.mozilla.org/attachment.cgi?id=190476&action=edit ...

Need help!!! (T.T) please help me......08/07/2007 i need the information....some people help me....
my qeustion is.....  how the ASP.NET allows programmers to use different programming languages in a same project every brother sister.....plesae help me.....i cant do it....cant understand it.......i must get information before 09/07/2007..... please help me....urgent...... Hi, please take a look at this article: Using VB.NET and C# in the same ASP.NET 2.0 project. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. hi.....Kris~~ Thanks a lot for ur help xD.... Very happy.....got nice people like you can help m...

Please help! My mozilla won't attempt to get email, but won't say why
Since 9/4, my Mozilla has apparently stopped attempting to receive email from a POP3 server. So far as I know, my server settings are OK with my ISP, and I can use Outlook Express successfully, so its not a problem with my ISP. Is there a log somewhere, or some other diagnostic? Thanks, Ben P On 10/09/2003 14:42, Ben Pracht wrote: > Since 9/4, my Mozilla has apparently stopped attempting to receive email > from a POP3 server. So far as I know, my server settings are OK with my > ISP, and I can use Outlook Express successfully, so its not a problem with > my ...

superreview requested: [Bug 300779] Support multiple selection for xul:tree : [Attachment 190476] Expose via a11y events. We don't need DOMItemSelected after all, they aren't fired for tree. We'll g #2
Aaron Leventhal <aaronleventhal@moonset.net> has asked Brian Ryner <bryner@brianryner.com> for superreview: Bug 300779: Support multiple selection for xul:tree https://bugzilla.mozilla.org/show_bug.cgi?id=300779 Attachment 190476: Expose via a11y events. We don't need DOMItemSelected after all, they aren't fired for tree. We'll go off of "select" DOM events later for the add/remove a11y events. https://bugzilla.mozilla.org/attachment.cgi?id=190476&action=edit ...

superreview requested: [Bug 300779] Support multiple selection for xul:tree : [Attachment 190476] Expose via a11y events. We don't need DOMItemSelected after all, they aren't fired for tree. We'll g #3
Aaron Leventhal <aaronleventhal@moonset.net> has asked Robert O'Callahan (Novell) <roc@ocallahan.org> for superreview: Bug 300779: Support multiple selection for xul:tree https://bugzilla.mozilla.org/show_bug.cgi?id=300779 Attachment 190476: Expose via a11y events. We don't need DOMItemSelected after all, they aren't fired for tree. We'll go off of "select" DOM events later for the add/remove a11y events. https://bugzilla.mozilla.org/attachment.cgi?id=190476&action=edit ...

help don't succeed in getting right data in my repeater
I am trying to show names and counts in a repeater. Have two tables here. Votes and Medicines. Votes has the votes and a foreign key (FK_MedicineID) to the Medicine table. I want to show the medicines with the most votes in a repeater (take the first 3) It works when i just want to show the FK_MedicineID, but I want to make the join to the Medicinetable and show the MedicineName... Somehow I don't see how to do this, because I use the select new { ... }; in my query. THis is my code: MMDataContext db = new MMDataContext(strConnection); var qmed = from vote in db.Vote...

Web resources about - Help needed - Can't get TADOQuery to select and display unicode data. - embarcadero.delphi.ado

Resources last updated: 12/8/2015 8:28:46 AM