我有一个文本框,我想将输出结果保存到 Unicode (SQL Server中的nvarchar
),对于我使用Entity Framework的保存操作,我的代码工作正常,我的问题只是将文本框结果转换为Unicode,因为当我保存结果时它保存为“?”在Sql Server中。
注意:我使用阿拉伯字母。,这是我的代码和列定义:
代码:
//Button add new car into database
private void BtnAddNewCar_Click(object sender, EventArgs e)
{
v.brand = TxBoxBrand.Text;
v.car_number = TxBoxCarNumber.Text;//Text Box that i want to convert to Unicode (Arabic letters)
v.color = CmBoxColorPicker.Text;
v.model = TxBoxModel.Text;
v.picture = ImageToByteArray(filename);
v.cin_driver= CmBoxCarOwner.Text;
context.Vehicles.Add(v);
context.SaveChanges();
NotifyWelcome.ShowBalloonTip(1000, "The vehicle " + TxBoxBrand.Text + " was successfully added", " Have a ice drive", ToolTipIcon.Info);
CarClear();
VLoad.Enabled = true;
CmVLoad.Enabled = false;
MyMessageBox.ShowBox("The vehicle " + TxBoxBrand.Text + " as successfully added", "Notify");
}
列定义:
// TxBoxCarNumber
//
this.TxBoxCarNumber.Font = new System.Drawing.Font("Ubuntu", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.TxBoxCarNumber.Location = new System.Drawing.Point(272, 30);
this.TxBoxCarNumber.Name = "TxBoxCarNumber";
this.TxBoxCarNumber.Size = new System.Drawing.Size(142, 21);
this.TxBoxCarNumber.TabIndex = 0;
this.TxBoxCarNumber.TabStop = false;