saminetemad
Programmer
Hello
I wantto tell you my problem as a example:
I have two textboxes and one button in the page. When I click on the button, MoneyManagement table in sql database is updated by text of textboxes .Type of this field are nvarchar
I wrote the following code :
protected void Button1_Click(object sender, EventArgs e)
{
string strconnection;
strconnection = ConfigurationSettings.AppSettings["connectionstring"];
SqlConnection DBConnection = new SqlConnection(strconnection);
DBConnection.Open();
string sql = "";
sql = "UPDATE MoneyManagement SET ";
sql += "Name=" + "'" +TextBox1.Text + "'" + ",";
sql += "Explain=" + "'" + TextBox2.Text + "'" + " ";
sql += "WHERE ID=2 ";
SqlCommand cmd = new SqlCommand(sql, DBConnection);
cmd.ExecuteNonQuery();
DBConnection.Close();
}
When the text of textboxes are English, this code works fine. but if text of textboxes are Persian this code doesn't work fine (In the database instead of text placed a question mark)
I'm not going to define the parameters. I want to send data with sql string.
I wantto tell you my problem as a example:
I have two textboxes and one button in the page. When I click on the button, MoneyManagement table in sql database is updated by text of textboxes .Type of this field are nvarchar
I wrote the following code :
protected void Button1_Click(object sender, EventArgs e)
{
string strconnection;
strconnection = ConfigurationSettings.AppSettings["connectionstring"];
SqlConnection DBConnection = new SqlConnection(strconnection);
DBConnection.Open();
string sql = "";
sql = "UPDATE MoneyManagement SET ";
sql += "Name=" + "'" +TextBox1.Text + "'" + ",";
sql += "Explain=" + "'" + TextBox2.Text + "'" + " ";
sql += "WHERE ID=2 ";
SqlCommand cmd = new SqlCommand(sql, DBConnection);
cmd.ExecuteNonQuery();
DBConnection.Close();
}
When the text of textboxes are English, this code works fine. but if text of textboxes are Persian this code doesn't work fine (In the database instead of text placed a question mark)
I'm not going to define the parameters. I want to send data with sql string.