Hi venkatg,
Use column datatype as NVARCHAR for saving any language (Hindi, Japanes, Urdu).
Check this example. Now please take its reference and correct your code.
Database
CREATE TABLE [dbo].[Languages]
(
[Language] [VARCHAR](50),
[Content] [NVARCHAR](1000)
)
Namespaces
using System.Configuration;
using System.Data.SqlClient;
Controller
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(string language, string content)
{
string constr = ConfigurationManager.ConnectionStrings["Constring"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
string query = "INSERT INTO Languages(Language, Content) VALUES(@Language, @Content)";
using (SqlCommand cmd = new SqlCommand(query))
{
cmd.Connection = con;
con.Open();
cmd.Parameters.AddWithValue("@Language", language);
cmd.Parameters.AddWithValue("@Content", content);
cmd.ExecuteNonQuery();
con.Close();
}
}
return RedirectToAction("Index");
}
}
View
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
@using (Html.BeginForm("Index", "Home", FormMethod.Post))
{
<table>
<tr>
<th colspan="2" align="center">Language Details</th>
</tr>
<tr>
<td>Language: </td>
<td>@Html.TextBox("language")</td>
</tr>
<tr>
<td>Content: </td>
<td>@Html.TextBox("content")</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" /></td>
</tr>
</table>
}
</body>
</html>
Screenshot
The Form
Database record after insert