SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["GVRAgencyConnectionString1"].ConnectionString);
con1.Open();
SqlDataAdapter da = new SqlDataAdapter("select weight,mrp_pack,no_of_pack,mrp_master_pack from dbo.purchase_order where [email protected]_ID",con1);
da.SelectCommand.Parameters.AddWithValue("@product_ID", DropDownList3.Text);
DataTable dt = new DataTable();
da.Fill(dt);
con1.Close();
DataRow row = dt.Rows[0];
txtwgt.Text = row["weight"].ToString();
txtmrpsinglepack.Text = row["mrp_pack"].ToString();
txtnoofmasterpack.Text = row["no_of_pack"].ToString();
txtmrpmaster.Text = row["mrp_master_pack"].ToString();
-1
A
回答
2
1)試試這個:
2)歡迎StackOverflow上。
3)如果你沒有女孩,你不能移動與一些女孩住在一起。
同樣在這裏 - 你不能在數據表withindex 0與記錄觸摸,如果你不知道你已經在索引中的行0
SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["GVRAgencyConnectionString1"].ConnectionString);
con1.Open();
SqlDataAdapter da = new SqlDataAdapter("select weight,mrp_pack,no_of_pack,mrp_master_pack from dbo.purchase_order where [email protected]_ID",con1);
da.SelectCommand.Parameters.AddWithValue("@product_ID", DropDownList3.Text);
DataTable dt = new DataTable();
da.Fill(dt);
con1.Close();
if (dt.Rows.Count==0) return;
DataRow row = dt.Rows[0];
txtwgt.Text = row["weight"].ToString();
txtmrpsinglepack.Text = row["mrp_pack"].ToString();
txtnoofmasterpack.Text = row["no_of_pack"].ToString();
txtmrpmaster.Text = row["mrp_master_pack"].ToString();
1
你的結果是空的,所以有沒有行的全部數據表。
if (dt.Rows.Count > 0) {
...
}
0
OracleConnection con = new OracleConnection(ConnectionString);
string selectquery = "SELECT TITLE,DESCRIPTION,SEVERITY,STATUS,IMPACT,USER_NAME AS CREATED_BY ,CREATED_DATE FROM Issues A, USERS B Where A.CREATED_BY=B.USER_ID AND A.ISSUE_ID=" + ID;
//string selectquery = "SELECT TITLE,DESCRIPTION,USER_NAME AS ASSIGNED_TO,SEVERITY,STATUS,IMPACT,USER_NAME AS CREATED_BY ,CREATED_DATE FROM Issues A, USERS B Where A.CREATED_BY=B.USER_ID AND A.ASSIGNED_TO=B.USER_ID AND A.ISSUE_ID=" + ID;
OracleDataAdapter adp = new OracleDataAdapter(selectquery, con);
DataTable dt = new DataTable();
adp.Fill(dt);
//GridView1.DataSource = dt;
// GridView1.DataBind();
lblTitle.Text = dt.Rows[0]["TITLE"].ToString();
lblDescription.Text = dt.Rows[0][1].ToString();
//lblSeverity.Text = dt.Rows[0][2].ToString();
lblStatus.Text = dt.Rows[0][3].ToString();
lblStatus.CssClass ="status"+ dt.Rows[0][3].ToString();
//lblImpact.Text = dt.Rows[0][4].ToString();
lblCreatedby.Text = dt.Rows[0][5].ToString();
lblcreateDate.Text = dt.Rows[0]["CREATED_DATE"].ToString();
//blCommentsDescriptionresult.Text = txtCommentdescription.Text;
相關問題
- 1. 沒有排在位置0查詢
- 2. C#在位置0處沒有行
- 3. C# - 位置0沒有行
- 4. 位置0處沒有行,例外
- 5. 在位置0沒有行OleDb數據庫
- 6. 有沒有排在posistion [0]
- 7. Stream.Seek(0,SeekOrigin.Begin)或位置= 0
- 8. 在位置0錯誤
- 9. C#「System.IndexOutOfRangeException:有沒有一行位置0」時,使用存儲過程
- 10. 沒有位置的行-1
- 11. mysql c api row [0] to string
- 12. VB.NET - 「位置0沒有行」但數據庫中的記錄
- 13. Viewpager位置0與使用onPageSelected(0)
- 14. 沒有紋理綁定到單位0
- 15. 匹配模式[0-9] - [0-9] - [0-9],但沒有匹配[0-9] - [0-9]
- 16. 有關位置0的Android GridView問題
- 17. Xcode - [UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]:row(7)beyond bounds(0)for section(0)。'
- 18. 舍入到0的位置#
- 19. PHP Help:if($ row ['cDeviceRegistrationId']> 0){$ a = 1;} echo $ a;
- 20. Php strrpos檢測到沒有字符串,總是0的位置
- 21. 「節點‘0’沒有位置 - 在networkX/Python的
- 22. Java,設置日期爲0/0/0
- 23. IE8底部:0位置:絕對行爲像位置:固定
- 24. 0 + 0 + 0 ... + 0!= 0
- 25. 返回 「批准」 列的值 「是\ 0 \ 0 \ 0 \ 0 \ 0 \ 0」,而不是 「是」
- 26. 插入0行沒有錯誤
- 27. 0如果沒有行存在
- 28. 如何設置顏色位置「0」 ExpandableListview
- 29. 有沒有辦法配置PHP,使echo 0 == 1;輸出0或錯誤?
- 30. Android IndexOutOfBound異常:位置0無效,大小爲0
這個錯誤意味着你的數據庫表'purchase_order'不含有'product_ID'等於在'選擇的值的任何記錄:
您可以嘗試訪問該行之前檢查此DropDownList3'。問題是什麼? – 2012-01-03 13:12:56
你應該寫一些關於你想要做什麼,以及你的問題是什麼,而不是隻發佈一些代碼和錯誤消息。您顯示的錯誤消息實際上是您的情況中的預期結果。 – Guffa 2012-01-03 13:15:10
謝謝你,先生,請幫助我先生,如果我需要編程幫助。 – 2012-01-04 07:50:03