In this article I will explain how to insert (save) Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters in MySql database using ASP.Net, C# and VB.Net.
In MySql database we will need to set UTF-8 Collation for the Table to store the various languages text characters.
 
Using MySQL with ASP.Net
This portion is extensively covered in my article Use and connect to MySQL Database in ASP.Net Application using MySQLConnector.
 
 
Database
For this article I have created a simple table with the following structure. Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters will be saved in the Content column which has a data type VARCHAR.
Insert Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters in MySql database using ASP.Net, C# and VB.Net
Note: You can download the database table SQL by clicking the download link below.
          Download SQL file
 
 
HTML Markup
The HTML Markup consists of an ASP.Net GridView a Button.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
    <asp:BoundField DataField="Language" HeaderText="Language" />
    <asp:BoundField DataField="Content" HeaderText="Content" />
</Columns>
</asp:GridView>
<br />
<asp:Button Text="Save" runat="server" OnClick ="Save" />
 
 
Namespaces
You will need to import the following namespaces.
C#
using System.Data;
using System.Configuration;
using MySql.Data.MySqlClient;
 
VB.Net
Imports System.Data
Imports System.Configuration
Imports MySql.Data.MySqlClient
 
 
Binding the GridView
The GridView is populated using Language Text characters of English, Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages.
For more information on this technique please refer:
 
C#
protected void Page_Load(object sender, EventArgs e)
{
    DataTable dt = new DataTable();
    dt.Columns.AddRange(new DataColumn[2] { new DataColumn("Language"), new DataColumn("Content") });
    dt.Rows.Add("English", "World is beautiful.");
    dt.Rows.Add("Hindi", "दुनियासुंदरहै।");
    dt.Rows.Add("Marathi", "जगसुंदरआहे.");
    dt.Rows.Add("Gujarati", "વિશ્વસુંદરછે.");
    dt.Rows.Add("Urdu", "دنیا خوبصورت ہے.");
    dt.Rows.Add("Persian", "جهانی زیبا است.");
    dt.Rows.Add("Arabic", "العالم هو جميل.");
    dt.Rows.Add("Tamil", "உலகஅழகாகஇருக்கிறது.");
    dt.Rows.Add("Telugu", "ప్రపంచఅందమైనఉంది.");
    GridView1.DataSource = dt;
    GridView1.DataBind();
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim dt As New DataTable()
    dt.Columns.AddRange(New DataColumn(1) {New DataColumn("Language"), New DataColumn("Content")})
    dt.Rows.Add("English", "World is beautiful.")
    dt.Rows.Add("Hindi", "दुनियासुंदरहै।")
    dt.Rows.Add("Marathi", "जगसुंदरआहे.")
    dt.Rows.Add("Gujarati", "વિશ્વસુંદરછે.")
    dt.Rows.Add("Urdu", "دنیا خوبصورت ہے.")
   dt.Rows.Add("Persian", "جهانی زیبا است.")
    dt.Rows.Add("Arabic", "العالم هو جميل.")
    dt.Rows.Add("Tamil", "உலகஅழகாகஇருக்கிறது.")
    dt.Rows.Add("Telugu", "ప్రపంచఅందమైనఉంది.")
    GridView1.DataSource = dt
    GridView1.DataBind()
End Sub
 
Insert Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters in MySql database using ASP.Net, C# and VB.Net
 
 
Insert (save) Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters in MySql Database
When the Save button is clicked the following event handler is executed inside which a loop is executed over the GridView Rows and one by one each Language content is inserted into the MySql database table.
C#
protected void Save(object sender, EventArgs e)
{
    string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
    using (MySqlConnection con = new MySqlConnection(constr))
    {
        foreach (GridViewRow row in GridView1.Rows)
        {
            using (MySqlCommand cmd = new MySqlCommand("INSERT INTO Languages VALUES(@Language, @Content)", con))
            {
                cmd.Parameters.AddWithValue("@Language", row.Cells[0].Text);
                cmd.Parameters.AddWithValue("@Content", row.Cells[1].Text);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
        }
    }
}
 
VB.Net
Protected Sub Save(sender As Object, e As EventArgs)
    Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString
    Using con As New MySqlConnection(constr)
        For Each row As GridViewRow In GridView1.Rows
            Using cmd As New MySqlCommand("INSERT INTO Languages VALUES(@Language, @Content)", con)
                cmd.Parameters.AddWithValue("@Language", row.Cells(0).Text)
                cmd.Parameters.AddWithValue("@Content", row.Cells(1).Text)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        Next
    End Using
End Sub
 
Insert Hindi, Marathi, Gujarati, Urdu, Persian, Arabic, Tamil and Telugu languages Text characters in MySql database using ASP.Net, C# and VB.Net
 
Downloads