嗯,我已經嘗試了所有你的人建議,但問題仍然相同特殊字符不顯示在GridView控件從SQL數據庫參數
讓我告訴你在簡短:
表姓名:AuzineForum。 ASPX
擁有1個GridView控件使用SELECT * FROM QF
其工作良好,指數也在努力,GridView控件有按鈕,顯示數據庫中的所有領域和onClick我打開新的表單AuzineForumAnswer.aspx ..OK
我想從AuzineForum.aspx中選擇一個記錄,並顯示在AuzineForumAnswer.aspx以及它發生在http://stackoverflow.com這裏(我們點擊線程然後新頁面打開其中有問題,並在其上點擊我們前面的答案)... OK
等AuzineForum.aspx的按鈕的代碼是
Button lb = (Button)sender;
GridViewRow row = (GridViewRow)lb.NamingContainer;
if (row != null)
{
int index = row.RowIndex; //gets the row index selected
Label AID1 = (Label)ForumQuesView.Rows[index].FindControl("AID1");
Label AID2 = (Label)ForumQuesView.Rows[index].FindControl("AID2");
Label AID3 = (Label)ForumQuesView.Rows[index].FindControl("AID3");
HyperLink Question = (HyperLink)ForumQuesView.Rows[index].FindControl("Question");
Label Questiontags = (Label)ForumQuesView.Rows[index].FindControl("Questiontags");
Label Askedby = (Label)ForumQuesView.Rows[index].FindControl("Askedby");
Response.Redirect(String.Format("AuzineForumAnswer.aspx?Question=" + Question.Text + "&Questiontags=" + Questiontags.Text + "&Askedby=" + Askedby.Text + "&AID1=" + AID1.Text + "&AID2=" + AID2.Text + "&AID3=" + AID3.Text, Server.UrlEncode(Question.Text), Server.UrlEncode(Questiontags.Text), Server.UrlEncode(Askedby.Text), Server.UrlEncode(AID1.Text), Server.UrlEncode(AID2.Text), Server.UrlEncode(AID3.Text)));
我有經過了太多的參數監守精度......
現在,當我運行它,然後單擊按鈕,它的開放AuzineForumAnswer.AuzineForumAnswerand顯示,記錄非常好,但出現問題時,qtags領域有「#」型喜歡這裏的標籤數據(C#,GridView的,等等),因此,當標記字段具有數據INCLUDIN「#」 chracter然後它給出「對象refrence不設置到對象的實例」,並且如果有qtags像正常數據(specialcharacter gridview的SQL C)然後將其打開AuzineForumAnswer。ASPX並沒有錯誤的數據顯示
AuzineForumAnswer.aspx後面的代碼如下
protected void GetAllData()
{
string connection = System.Configuration.ConfigurationManager.ConnectionStrings["AuzineConnection"].ConnectionString;
using (SqlConnection sqlconn = new SqlConnection(connection))
{
using (SqlCommand sqlcomm = sqlconn.CreateCommand())
{
sqlcomm.CommandText = "Select * From QF where Question='" + Server.UrlDecode(Request.QueryString["Question"].ToString()) + "' And qtags='" + Server.UrlDecode(Request.QueryString["Questiontags"].ToString()) + "' And UserFullName='" + Server.UrlDecode(Request.QueryString["Askedby"].ToString()) + "' And AID1='" + Server.UrlDecode(Request.QueryString["AID1"].ToString()) + "' And AID2='" + Server.UrlDecode(Request.QueryString["AID2"].ToString()) + "' And AID3='" + Server.UrlDecode(Request.QueryString["AID3"].ToString()) + "'";
SqlDataAdapter sda = new SqlDataAdapter(sqlcomm);
DataTable dt = new DataTable();
sda.Fill(dt);
try
{
sqlconn.Open();
ForumQuesView.DataSource = dt;
ForumQuesView.DataBind();
ForumQuesView.AllowPaging = true;
}
catch (Exception ex)
{
Status.Text = ex.Message.ToString();
}
}
}
}
現在我也搞不懂什麼問題在這裏,因爲只有qtags和的問題有兩個網絡連接場中,用戶可以儲存數據,因爲他們想要的,問題是文字和qtags而且都煤焦領域,但問題並不在數據庫中的問題是在這裏以字符#
您是否嘗試過調試和看到的是創造了什麼SQL語句?發佈該sql語句。 – unlimit
調試,獲取查詢並在sql server中運行它。我什麼也沒有出錯,那麼你的任何對象的初始化必須有問題 - 「對象引用沒有設置爲對象的實例」 – polin
親愛的波林,我也同意你的意見,但我所說的是......我在qtags列中有很多行,通過單擊任何行都沒有出錯,但具有「#」字符的行會給出錯誤,並且當我直接轉到SQL Server以更改行內部時,它會給出錯誤「Binary data將被截斷「現在這個錯誤來時,限制超過,但一切都很好,我不明白我在哪裏犯的錯誤 –