Click here to Skip to main content
15,889,436 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am developing a website in marathi . I want save data in marathi in database .i am unable to save it. I tried the solutons given on codeproject but was unable to save it.
I used nvarchar(max) datatype and prefixed the values by N while inserting but it inserts values @name,@address....
my code is as follows


नाव : <asp:TextBox ID="txtName" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Font-Size="Medium" Height="23px" Width="132px">
वडिलांचे नाव <asp:TextBox ID="txtMiddleName" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">
आडनाव <asp:TextBox ID="txtSurname" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">
लिंग            
<asp:RadioButtonList ID="rdGender" runat="server" Height="51px" Width="106px" Font-Names="Shivaji05">
<asp:ListItem Value="M">पुरूष
<asp:ListItem Value="F">स्त्री

जन्म दिनांक <asp:TextBox ID="txtDOB" runat="server" TextMode="Date" CssClass="validate[required]" Font-Names="Rod" Height="23px" Width="132px"> जन्म स्थान <asp:TextBox ID="txtbrtplace" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">
जन्म वेळ <asp:TextBox ID="txtbrtTime" runat="server" CssClass="validate[required]" Height="23px" Width="132px"> उंची <asp:DropDownList ID="ddHeight" runat="server" CssClass="validate[required]">
<asp:ListItem>
<asp:ListItem>Below 4ft
<asp:ListItem>4ft 6in
<asp:ListItem>4ft 7in
<asp:ListItem>4ft 8in
<asp:ListItem>4ft 9in
<asp:ListItem>4ft 10in
<asp:ListItem>4ft 11in
<asp:ListItem>5ft
<asp:ListItem>5ft 1in
<asp:ListItem>5ft 2in
<asp:ListItem>5ft 3in
<asp:ListItem>5ft 4in
<asp:ListItem>5ft 5in
<asp:ListItem>5ft 6in
<asp:ListItem>5ft 7in
<asp:ListItem>5ft 8in
<asp:ListItem>5ft 9in
<asp:ListItem>5ft 10in
<asp:ListItem>5ft 11in
<asp:ListItem>6ft
<asp:ListItem>6ft 1in
<asp:ListItem>6ft 2in
<asp:ListItem>6ft 3in
<asp:ListItem>6ft 4in
<asp:ListItem>6ft 5in
<asp:ListItem>6ft 6in
<asp:ListItem>6ft 7in
<asp:ListItem>6ft 8in
<asp:ListItem>6ft 9in
<asp:ListItem>6ft 10in
<asp:ListItem>6ft 11in
<asp:ListItem>7ft
<asp:ListItem>Above 7ft

वजन <asp:DropDownList ID="ddWeight" runat="server" CssClass="validate[required]">
<asp:ListItem>
<asp:ListItem>41kg
<asp:ListItem>42kg
<asp:ListItem>43kg
<asp:ListItem>44kg
<asp:ListItem>45kg
<asp:ListItem>46kg
<asp:ListItem>47kg
<asp:ListItem>48kg
<asp:ListItem>49kg
<asp:ListItem>50kg
<asp:ListItem>51kg
<asp:ListItem>52kg
<asp:ListItem>53kg
<asp:ListItem>54kg
<asp:ListItem>55kg
<asp:ListItem>56kg
<asp:ListItem>57kg
<asp:ListItem>58kg
<asp:ListItem>59kg
<asp:ListItem>60kg
<asp:ListItem>61kg
<asp:ListItem>62kg
<asp:ListItem>63kg
<asp:ListItem>64kg
<asp:ListItem>65kg
<asp:ListItem>66kg
<asp:ListItem>67kg
<asp:ListItem>68kg
<asp:ListItem>69kg
<asp:ListItem>70kg
<asp:ListItem>71kg
<asp:ListItem>72kg
<asp:ListItem>73kg
<asp:ListItem>74kg
<asp:ListItem>75kg
<asp:ListItem>76kg
<asp:ListItem>77kg
<asp:ListItem>78kg
<asp:ListItem>79kg
<asp:ListItem>80kg
<asp:ListItem>81kg
<asp:ListItem>82kg
<asp:ListItem>83kg
<asp:ListItem>84kg
<asp:ListItem>85kg
<asp:ListItem>86kg
<asp:ListItem>87kg
<asp:ListItem>88kg
<asp:ListItem>89kg
<asp:ListItem>90kg
<asp:ListItem>91kg
<asp:ListItem>92kg
<asp:ListItem>93kg
<asp:ListItem>94kg
<asp:ListItem>95kg
<asp:ListItem>96kg
<asp:ListItem>97kg
<asp:ListItem>98kg
<asp:ListItem>99kg
<asp:ListItem>100kg
<asp:ListItem>101kg
<asp:ListItem>102kg
<asp:ListItem>103kg
<asp:ListItem>104kg
<asp:ListItem>105kg
<asp:ListItem>106kg
<asp:ListItem>107kg
<asp:ListItem>108kg
<asp:ListItem>109kg
<asp:ListItem>110kg
<asp:ListItem>111kg
<asp:ListItem>112kg
<asp:ListItem>113kg
<asp:ListItem>114kg
<asp:ListItem>115kg
<asp:ListItem>116kg
<asp:ListItem>117kg
<asp:ListItem>118kg
<asp:ListItem>119kg
<asp:ListItem>120kg
<asp:ListItem>121kg
<asp:ListItem>122kg
<asp:ListItem>123kg
<asp:ListItem>124kg
<asp:ListItem>125kg
<asp:ListItem>126kg
<asp:ListItem>127kg
<asp:ListItem>128kg
<asp:ListItem>129kg
<asp:ListItem>130kg
<asp:ListItem>131kg
<asp:ListItem>132kg
<asp:ListItem>133kg
<asp:ListItem>134kg
<asp:ListItem>135kg
<asp:ListItem>136kg
<asp:ListItem>137kg
<asp:ListItem>138kg
<asp:ListItem>139kg
<asp:ListItem>140kg
<asp:ListItem>141kg
<asp:ListItem>142kg
<asp:ListItem>143kg
<asp:ListItem>144kg
<asp:ListItem>145kg
<asp:ListItem>146kg
<asp:ListItem>147kg
<asp:ListItem>148kg
<asp:ListItem>149kg
<asp:ListItem>150kg
रक्तगट <asp:DropDownList ID="ddBloodgrp" runat="server" CssClass="validate[required]">
<asp:ListItem>
<asp:ListItem>A+
<asp:ListItem>A-
<asp:ListItem>AB+
<asp:ListItem>AB-
<asp:ListItem>B+
<asp:ListItem>B-
<asp:ListItem>O+
<asp:ListItem>O-
शारीरिक व्यंग <asp:RadioButtonList ID="rdph" runat="server" >
<asp:ListItem>होय
<asp:ListItem>नाही

वैवाहिक स्थिती <asp:DropDownList ID="ddMaritalStatus" runat="server" CssClass="validate[required]">
<asp:ListItem>
<asp:ListItem>अविवाहीत
<asp:ListItem>घटस्फोटीत
<asp:ListItem>विधवा
शिक्षण <asp:TextBox ID="txtEducation" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px"> व्यवसाय / नोकरी <asp:TextBox ID="txtJob" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px"> उत्पन्न <asp:TextBox ID="txtIncome" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">
वय <asp:TextBox ID="txtAge" runat="server" CssClass="validate[required]">

कौटुंबिक माहिती.



वडिलांचे नाव <asp:TextBox ID="txtFathersName" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px"> आईचे नाव <asp:TextBox ID="txtMothersName" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px"> वडिलांचे व्यवसाय/नोकरी <asp:TextBox ID="txtFatherjob" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">
भाऊ <asp:TextBox ID="txtNobrother" runat="server" CssClass="validate[required]" Height="23px" Width="132px"> बहीण <asp:TextBox ID="txtNoSister" runat="server" CssClass="validate[required]" Height="23px" Width="132px"> मामांचे नाव <asp:TextBox ID="txtMamaName" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">
मामांचा पत्ता <asp:TextBox ID="txtMamaAddr" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px"> मामांचा व्यवसाय <asp:TextBox ID="txtMamaJob" runat="server" CssClass="validate[required]" Font-Names="Shivaji05" Height="23px" Width="132px">




रास <asp:DropDownList ID="ddras" runat="server" CssClass="validate[required]">
<asp:ListItem>
<asp:ListItem>मेष
<asp:ListItem>वृषभ
<asp:ListItem>मिथुन
<asp:ListItem>कर्क
<asp:ListItem>सिंह
<asp:ListItem>कन्या
<asp:ListItem>तूळ
<asp:ListItem>वृश्चिक
<asp:ListItem>धनु
<asp:ListItem>मकर
<asp:ListItem>कुंभ
<asp:ListItem>मीन
गन <asp:DropDownList ID="ddgan" runat="server" CssClass="validate[required]">
<asp:ListItem>
<asp:ListItem>देव
<asp:ListItem>मनुष्य
<asp:ListItem>राक्षस
मंगळ            
<asp:RadioButtonList ID="rdMaglik" runat="server">
<asp:ListItem>होय
<asp:ListItem>नाही

देवक <asp:TextBox ID="txtdevak" runat="server" Font-Names="Shivaji05" Height="23px" Width="132px"> गोत्र <asp:TextBox ID="txtgotra" runat="server" Font-Names="Shivaji05" Height="23px" Width="132px">

संपर्क तपशील



पत्ता <asp:TextBox ID="txtAddre" runat="server" CssClass="validate[required]" Height="105px" TextMode="MultiLine" Font-Names="Shivaji02" Width="160px"> ईमेल <asp:TextBox ID="txtEmail" runat="server" CssClass="validate[required,custom[email]" Height="23px" Width="132px"> मोबाईल क्रमांक <asp:TextBox ID="txtMobileNo" runat="server" CssClass="validate[required]" Height="23px" Width="132px">



User ID <asp:TextBox ID="txtuserid" runat="server" CssClass="validate[required]" Height="23px" Width="132px">

फोटो अपलोड




फोटो <asp:FileUpload ID="FileUpload1" runat="server" CssClass="validate[required]"/>


                                                                                    <asp:Button ID="btnSubmit" runat="server" Text="सबमिट" Width="112px" OnClick="btnSubmit_Click" /> <asp:Button ID="btnreset" runat="server" Text="रीसेट" Width="112px" />


and c# code is :protected void btnSubmit_Click(object sender, EventArgs e)
{
paswd = this.getrandomno();
try
{

string Height = ddHeight.SelectedValue.ToString();
string weight = ddWeight.SelectedValue.ToString();
string ras = ddras.SelectedValue.ToString();
string gan = ddgan.SelectedValue.ToString();
string bloodgrp = ddBloodgrp.SelectedValue.ToString();
string maritalStatus = ddMaritalStatus.SelectedValue.ToString();
int len = FileUpload1.PostedFile.ContentLength;
byte[] pic = new byte[len];
HttpPostedFile img = FileUpload1.PostedFile;
FileUpload1.PostedFile.InputStream.Read(pic, 0, len);
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["MahatmaPhule"].ToString();
con.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO userRegistration(firstName,middleName,lastName,gender,dob,birthplace,birthtime,height,weight,bloodgrp,physicalStatus,maritalstatus,education,occupation,income,fatherName,motherName,fatherOccupation,nofbrother,nofsister,mamaName,mamaAddress,mamaOccupation,ras,gan,manglik,devak,gothra,address,email,mobileNo,userId,photo) VALUES(N'@firstName',N'@middleName',N'@lastName',N'@gender',@dob,N'@birthplace',@birthtime,@height,@weight,@bloodgrp,N'@physicalStatus',N'@maritalstatus',N'@education',N'@occupation',@income,N'@fatherName',N'@motherName',N'@fatherOccupation',@nofbrother,@nofsister,N'@mamaName',N'@mamaAddress',N'@mamaOccupation',N'@ras',N'@gan',N'@manglik',N'@devak',N'@gothra',N'@address',@email,@mobileNo,@userId,@photo)", con);
cmd.Connection = con;

cmd.Parameters.AddWithValue("@firstName", txtName.Text);
cmd.Parameters.AddWithValue("@middleName", txtMiddleName.Text);
cmd.Parameters.AddWithValue("@lastName", txtSurname.Text);
cmd.Parameters.AddWithValue("@gender", rdGender.SelectedValue);
cmd.Parameters.AddWithValue("@dob", txtDOB.Text);
cmd.Parameters.AddWithValue("@birthplace", txtbrtplace.Text);
cmd.Parameters.AddWithValue("@birthtime", txtbrtTime.Text);
cmd.Parameters.AddWithValue("@height", Height);
cmd.Parameters.AddWithValue("@weight", weight);
cmd.Parameters.AddWithValue("@bloodgrp", bloodgrp);
cmd.Parameters.AddWithValue("@physicalStatus", rdph.SelectedValue);
cmd.Parameters.AddWithValue("@maritalstatus", maritalStatus);
cmd.Parameters.AddWithValue("@education", txtEducation.Text);
cmd.Parameters.AddWithValue("@occupation", txtJob.Text);
cmd.Parameters.AddWithValue("@income", txtIncome.Text);
cmd.Parameters.AddWithValue("@fatherName", txtFathersName.Text);
cmd.Parameters.AddWithValue("@motherName", txtMothersName.Text);
cmd.Parameters.AddWithValue("@fatherOccupation", txtFatherjob.Text);
cmd.Parameters.AddWithValue("@nofbrother", txtNobrother.Text);
cmd.Parameters.AddWithValue("@nofsister", txtNoSister.Text);
cmd.Parameters.AddWithValue("@mamaName", txtMamaName.Text);
cmd.Parameters.AddWithValue("@mamaAddress", txtMamaAddr.Text);
cmd.Parameters.AddWithValue("@mamaOccupation", txtMamaJob.Text);
cmd.Parameters.AddWithValue("@ras", ras);
cmd.Parameters.AddWithValue("@gan", gan);
cmd.Parameters.AddWithValue("@manglik", rdMaglik.SelectedValue);
cmd.Parameters.AddWithValue("@devak", txtdevak.Text);
cmd.Parameters.AddWithValue("@gothra", txtgotra.Text);
cmd.Parameters.AddWithValue("@address", txtAddre.Text);
cmd.Parameters.AddWithValue("@email", txtEmail.Text);
cmd.Parameters.AddWithValue("@mobileNo", txtMobileNo.Text);
cmd.Parameters.AddWithValue("@userId", txtuserid.Text);
cmd.Parameters.AddWithValue("@photo", pic);
int c = cmd.ExecuteNonQuery();
if (c > 0)
{
string strScript = "<script language='JavaScript'>alert('Records Inserted Successfully!')</script>";
Page.RegisterStartupScript("PopUp", strScript);
}
else
{
string strScript = "<script language='JavaScript'>alert('Records Not Inserted Successfully!')</script>";
Page.RegisterStartupScript("PopUp", strScript);
}

}
catch (Exception ex)
{
throw ex;
}

plz help me to solve this problem
its shows output as @firstName,@middleName.......
Posted

 
Share this answer
 
v3
Comments
Devendra Dighe 23-Apr-14 2:52am    
@ravikhoda : all my database fields are NVARCHAR
ravikhoda 23-Apr-14 2:55am    
well in your query i think remove the N which you have added before all the parameters. if you have nvarchar set in the database it should automatically take it.
Devendra Dighe 23-Apr-14 3:00am    
if i remove N from query then it converts data in english
ravikhoda 23-Apr-14 3:08am    
hi , please check ans again added one link for the same situation.
Hi,

Remove 'N' prefix from your parameter.
 
Share this answer
 
Comments
Devendra Dighe 23-Apr-14 3:02am    
@Bh@gyesh: if i remove N from query then it converts data in english
Bh@gyesh 23-Apr-14 4:53am    
Hi Devendra,

I have tested following scenario in SQL and its working fine :

declare @test nvarchar(max)

Set @test = N'सहाय'

INSERT [dbo].[Table_1] ([Test], [Test1]) VALUES (N'3', @test)

So, Add 'N' as following in your code
cmd.Parameters.AddWithValue("@firstName", 'N'+txtName.Text);
cmd.Parameters.AddWithValue("@middleName", 'N'+txtMiddleName.Text);

etc...

and remove 'N' from parameter list.

Let me know in case of any issue...
Devendra Dighe 23-Apr-14 9:52am    
Hi Bh@gyesh ,
I tried your solution but in database it prints values prefix with N and in english
eg: it prints NDevendra,....
here are changes I made
cmd.Parameters.AddWithValue("@firstName", 'N'+txtName.Text);
cmd.Parameters.AddWithValue("@middleName", 'N'+txtMiddleName.Text);
cmd.Parameters.AddWithValue("@lastName", 'N'+txtSurname.Text);
cmd.Parameters.AddWithValue("@gender", 'N'+rdGender.SelectedValue);
and so on.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900