473,765 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display Urdu Unicode characters on my Windows Forms

shahhussain305
4 New Member
Hay, I tried to get the Urdu Fonts from MySql Database using C# in Visual Studio 2010 in Windows Forms Application. When I get the value from table into my variable it shows the characters in ???? symbols. wherein PHP it is working very good without any problem.
But in PHP i have used the following code:
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2.     class CRUD {
  3.         var $con; 
  4.         //function to make connection to database
  5.         function connect(){
  6.             $this->con = mysql_connect("localhost","root","password") or die(mysql_error());            
  7.             mysql_query("SET character_set_results=utf8", $this->con);
  8.             mb_language('uni');
  9.             mb_internal_encoding('UTF-8');
  10.             mysql_select_db("database1",$this->con);
  11.             mysql_query("set names 'utf8'",$this->con);                
  12.             }
  13.                 //function to get the field value from the table specified in the query
  14.         function getValue($sql,$value){
  15.             $this->connect();
  16.             $result = mysql_query($sql,$this->con);
  17.             if(mysql_num_rows($result) > 0) {
  18.                 $row = mysql_fetch_array($result);
  19.                     $value = $row[$value];
  20.                 }
  21.             else {
  22.                     $value = "";
  23.                 }
  24.                 return $value;
  25.             }
  26.                     ?>
Now I do not know how to insert this line of code to my query in C#:

Expand|Select|Wrap|Line Numbers
  1. mysql_query("SET character_set_results=utf8", $this->con);
  2.             mb_language('uni');
  3.             mb_internal_encoding('UTF-8');
  4.             mysql_select_db("database1",$this->con);
  5.             mysql_query("set names 'utf8'",$this->con);
I am using the following code in my C# class:
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.Sql;
  6. using System.Data.Odbc;
  7. using System.Data;
  8. using System.Windows.Forms;
  9.  
  10. namespace Madrasa_Mgt.classes
  11. {
  12.     class CRUD
  13.     {
  14.         private static string userid;
  15.         private static string userkey;
  16.         private OdbcConnection con;
  17.         private OdbcDataReader odr;
  18.         private OdbcCommand cmd;
  19.         public bool flag;
  20.         UTF8Encoding utf8 = new UTF8Encoding();
  21.  
  22.  
  23.         public CRUD() {
  24.             //connectToDb();
  25.             setVars();
  26.  
  27.         }
  28.  
  29.     private OdbcConnection connectToDb(){
  30.         try {
  31.             con = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; uid=root; password=thefire; Server=localhost; Option=16834; Database=madrasa_jamia");
  32.             if (con.State == ConnectionState.Closed) {
  33.                 con.Open();
  34.             }
  35.         }
  36.         catch (Exception exc) {
  37.             this.msgErrorEx(exc);   
  38.         }
  39.         return con;
  40.     }
  41.  
  42.     private void setVars() {
  43.         try {
  44.             this.connectToDb();
  45.             string sql = "SELECT mad_name,mad_addr,phone,banner_photo,owner_name,licence_number,purchase_date,vendor_name,vendor_addr,vendor_phone,is_ok FROM configuration";
  46.             cmd = new OdbcCommand(sql, this.con);
  47.             cmd.ExecuteNonQuery();
  48.             odr = cmd.ExecuteReader();
  49.             if (odr.Read())
  50.             {
  51.                GlobalVars.MadName = odr["mad_name"];
  52.                GlobalVars.MadrasaAddress = odr["mad_addr"];
  53.                GlobalVars.Phone = odr["phone"];
  54.                GlobalVars.Banner = odr["banner_photo"];
  55.                GlobalVars.OwnerName = odr["owner_name"];
  56.                GlobalVars.LicenseNumber = odr["licence_number"];
  57.                GlobalVars.PurchasedDate = odr["purchase_date"];
  58.                GlobalVars.VendorName = odr["vendor_name"];
  59.                GlobalVars.VendorAddress = odr["vendor_addr"];
  60.                GlobalVars.VendorPhone = odr["vendor_phone"];
  61.                GlobalVars.IsOk = odr["is_ok"];
  62.             }
  63.         }
  64.         catch (Exception exc) { 
  65.         }
  66.     }
  67.  
and I am getting the following error message:
class System.String
Represents text as a series of Unicode characters.
Error:
Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)


Please help me in this regards. Thanks in advance.
Shah Hussain
Aug 3 '12 #1
3 5900
Aimee Bailey
197 Recognized Expert New Member
I just came across your question, and realised I had a bookmark that may be really relevant here:

http://www.joelonsoftware.com/printe...s/Unicode.html

It's an old article, but hopefully it'll prove of some use to you. All the best!

Aimee.
Aug 15 '12 #2
ariful alam
185 New Member
You are showing your data from MySql to any text box or control of your Visul Studio 2010 windows application. the controls font are a ASCII font by default. try by changing those controls font to a Unicode font. It may work.

Hope it's help you. :)
Aug 15 '12 #3
shahhussain305
4 New Member
hay, Ariful Alam and Aimee bailey first of all let me say you thanks for reply. but before going forth, let me say that i have resolved by updating my installed driver for MySQL, actually i was using MySQL driver version 3.x which was not support to send and or retrieve data as in Unicode format from MySQL databse. when i update MySQL driver and then run the application it works nicely and now its working without any problem.
Thanks and regard.
Shah Hussain
Aug 15 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3083
by: SB | last post by:
Hi, I'd like to display some non-ascii characters in a DOS window. I'm getting the characters from Windows Character Map, such as the Spade (U+2660) and a few others. However, I can't get it to work. I know the characters I'm trying to display are Unicode and that is presenting the problem. Does anyone know how to do this if even possible? Thanks!
5
5135
by: Borko | last post by:
hi I am having problems getting unicode characters into VB. Using VB6 (sp3) and Access 2000 Characters are displayed correctly in Access, just when I use ADODB (2.7) to read them in VB i get ? character instead of unicode characters. I will display them in TreeView (capable of Unicode) Is there any patch, fix or something, I know this thing is going around
1
2943
by: fredy | last post by:
how to display a webpage in windows forms, i'm writing a windows forms app. how can i display a webpage without having to write a web application???
12
3892
by: Onega | last post by:
Hi I create a simple win32 project (VC2003, windows2003(English) , and do simple paint in WM_PAINT message, when the project use multi-character set, it is OK. but when I change to UNICODE, some Chinese characters are illegible( I see sizeof(TCHAR)=2 being displayed). Your idea is welcome. case WM_PAINT: hdc = BeginPaint(hWnd, &ps);
3
5470
by: Kidus Yared | last post by:
I am having a problem displaying Unicode characters on my Forms labels and buttons. After coding Button1.Text = unicode; where the unicode is a Unicode character or string (‘\u1234’ or “\u1234”) It seems to work the first time I set the button to the Unicode character. After a while, when saving my code, I get a pop-up window stating that I need to save the file as a Unicode else my changes will not be saved. Seance I do not want...
5
4077
by: Matthew Thompson | last post by:
I have as issue I am finding hard to research. I use a stored proecdure in SQL 2000 to provide search capability for our database of news stories and articles. Being an international magazine publisher we use foreign characters extensively. When searching for words (I am using Full Text Indexing and using the CONTAINSTABLE method) with accented characters such as Mller (Second character is Alt+0248) the form receives back Møller
1
1055
by: jimmyk | last post by:
Hello, please help me I made a windows application by VB.NET. Everthing is ok if i run it on Windows xp, unicode-font objects display properly. But when i run it on windows 9x (installed unicode fonts already), only BUTTON display unicode fonts properly, TEXTBOX can't display unicode fonts. WHY? Please tell the solutions. I heard that MSLU (for win 9x) can solve the problem but i don't know how to use it in VB.NET.
6
5988
by: Bill Nguyen | last post by:
I'm getting data from a mySQL database (default char set = UTF-8). I need to display data in Unicode but got only mongolian characters like this: Phạm Thị Ngọc I changed the textbox font to Arial Unicode MS but still not working. Do I need conversion of data stored in mySQL database before displaying? Thanks Bill
0
1048
pentahari
by: pentahari | last post by:
how to display the unicode characters in controls such as textbox, label and listbox, etc using VB.
6
10717
vekipeki
by: vekipeki | last post by:
I am having a problem with basic drawing of unicode characters in Windows 2000 and XP. I have written a simplest possible C# WinForms program to test it (just create a new Windows Forms C# application and add a Paint event handler): public partial class Form1 : Form { public Form1() { InitializeComponent();
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.