由于我还没有找到我之前的问题(链接)的解决方案,我发布了一个新问题,希望有一个解决方案。如果我违反了规则,我很抱歉,但我还没有收到解决方案。
当我尝试更新一行时,我已经跟踪了发送的查询,例如:
UPDATE global_status SET title = 'Login_Failure', info = 'שדכ' WHERE id = '2'
所以你可以看到发送的最终查询是希伯来语的,所以在此之前它不是问题。我这样执行它:
string Status_Update = "UPDATE global_status SET title = '" + Title + "', info = '" + Info + "' WHERE id = '" + Request.Form["Status_Key"] + "'";
MyAdoHelper.DoQuery(GlobalVar.DatabaseName, Status_Update);
方法:
public static void DoQuery(string fileName, string sql)
{
SqlConnection conn = ConnectToDb(fileName);
conn.Open();
SqlCommand com = new SqlCommand(sql, conn);
com.ExecuteNonQuery();
com.Dispose();
conn.Close();
}
更新后,数据库包含??? 我插入希伯来字母的地方。
我可以手动将希伯来语值插入数据库,也可以将它们取回。
我有另一种形式(注册),我可以在其中插入希伯来语值,使用 DoQuery();
这是更新页面的源代码(它正在更新记录的标题和信息,没什么特别的):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
public partial class admin_EditGlobalStatus : System.Web.UI.Page
{
public string StatusesTable;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Form["Status_Update"] != null)
{
string Title = Request.Form["Status_Title"].Secure();
string Info = Request.Form["Status_Info"].Secure();
Info = Info.Replace("/s", "<span class\"res\">").Replace("/e", "</span>");
string Status_Update = "UPDATE global_status SET title = '" + Title + "', info = '" + Info + "' WHERE id = '" + Request.Form["Status_Key"] + "'";
MyAdoHelper.DoQuery(GlobalVar.DatabaseName, Status_Update);
}
if (Request.Form["Status_Delete"] != null)
{
string Status_Delete = "DELETE FROM global_status WHERE id = '" + Request.Form["Status_Key"] + "'";
MyAdoHelper.DoQuery(GlobalVar.DatabaseName, Status_Delete);
}
string GetGlobalStatuses = "SELECT * FROM global_status";
DataTable dt = MyAdoHelper.ExecuteDataTable(GlobalVar.DatabaseName, GetGlobalStatuses);
if (dt.Rows.Count > 0)
{
StatusesTable = "<table cellspacing=\"15\">";
StatusesTable += "<th>כותרת ההודעה</th><th>מידע ההודעה</th>";
foreach (DataRow status in dt.Rows)
{
StatusesTable += "<tr><form method=\"post\" action=\"\">";
StatusesTable += "<input type=\"hidden\" name=\"Status_Key\" value=\"" + status["id"].ToString() + "\" />";
StatusesTable += "<td><input size=\"25\" dir=\"ltr\" type=\"text\" name=\"Status_Title\" value=\"" + status["title"].ToString() + "\" /></td>";
StatusesTable += "<td><input size=\"90\" type=\"text\" name=\"Status_Info\" value=\"" + status["info"].ToString().Secure() + "\" /></td>";
StatusesTable += "<td><input type=\"submit\" name=\"Status_Update\" value=\"עדכן\"><input type=\"submit\" name=\"Status_Delete\" value=\"מחק\"></td></form></tr>\r\n";
}
StatusesTable += "</table>";
}
else
{
StatusesTable = "<h1>אין משתמשים קיימים</h1>";
}
}
}
希望有解决办法,谢谢!
盖伊