Showing posts with label 2012. Show all posts
Showing posts with label 2012. Show all posts

Wednesday, 31 January 2018

Multilingual .NET Application using SQL Server

I was tasked with a project and a very small portion of it was to insert Multilingual Characters into the SQL Server database using C# .NET

Although it’s a simple enough task once I googled and got information from here and there.
Here is my compilation of Step by Step guide, Hope this is helpful.

First Let’s Setup the Database table


SQL Query for creating Table 

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[tbl_MultiLang](
    [Lang] [nvarchar](50) NULL,
    [Data] [nvarchar](50) NULL
) ON [PRIMARY]

GO

Let's setup a simple table with two columns, First is "Lang" of nvarchar that will have only English characters  and the second Data of nvarchar this will host Multilingual characters.



SQL Queries
Queries for Insert into table 
Key here is having "N" before inserting the Multilingual character or string

INSERT INTO tbl_MultiLang (Lang, Data) values(N'English',N'Hello')
INSERT INTO tbl_MultiLang (Lang, Data) values(N'Urdu',N'ہیلو')



SQL Output
Queries for Insert into table



C# Code
Following is the C# Code, illustrating the INSERT statement from the C# Application.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
private void button1_Click_1(object sender, EventArgs e)
{
            SqlConnection conn = new SqlConnection("server=****;database=testdb;uid=****;password=****");
            SqlCommand cmd;
            try
            {
                conn.Open();
                cmd = new SqlCommand("INSERT INTO tbl_MultiLang (Lang, Data) values(N'"+ tboxLang.Text +"',N'"+ tboxData.Text +"')", conn);
                cmd.ExecuteNonQuery();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error ", ex.Message);
            }
}



I haven't shown any read-back C# code from DB as it is straight-forward.

I found this article particularly interesting and also my Reference
http://installurdu.blogspot.sg/p/insert-urdu-characters-in-sql-server.html

Tuesday, 14 February 2017

Installing .NET Framework 3.5 on Windows 2012


Installing .NET Framework 3.5 on Windows 2012
Installing .NET Framework is a bit different from the standard way like other Roles or Features are installed.

Following is the command
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:d:\sources\sxs

Command Parameters:
/Online targets the operating system you're running (instead of an offline Windows image).
/Enable-Feature /FeatureName:NetFx3 specifies that you want to enable the .NET Framework 3.5.
/All enables all parent features of the .NET Framework 3.5.
/LimitAccess prevents DISM from contacting Windows Update.
/Source specifies the location of the files needed to restore the feature (example, the D:\sources\sxs directory or a network location using \\ we will be using network location in the example below).

Example