日期:2014-05-18 浏览次数:20717 次
DataSet data = new DataSet(); data.ReadXml(@"\abcd.xml"); for (int i = 0; i < data.Tables[0].Rows.Count; i++) { DR = data.Tables[0].Rows[i]; string barcode = DR["barcode"].ToString(); if (barcode == textBox1.Text) { textBox2.Text = DR["productname"].ToString(); menuItem1.Enabled = false; menuItem2.Enabled = true; } }
data!=null&&data.Tables[0].Rows.Count>0
------解决方案--------------------
判断data.Tables的count