C#问题,请各位帮我找一下错误,提示
未将对象引用设置到对象实例!散分!
请各位帮我找一下错误!急!未将对象引用设置到对象实例
代码如下:
我写代码功能是建数组,然后存儲打印
public struct Print
{
public Item[] Arr;
}
public struct Item
{
public string PsId;
public string CusNo;
public string PsNo;
public string OsNo;
public string PrdName;
public string Qty;
public string Up;
public string AmtnNet;
public string Tax;
public string InvNo;
public string Snm;
}
...........
protected Print one = new Print();
protected Item item = new Item();
........
//收集数据代码
private void GetSA(string startDate,string endDate)
{
using(SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
string SQL_SELECT_SA = "SELECT MF_PSS.PS_ID, MF_PSS.CUS_NO, MF_PSS.PS_NO, MF_PSS.OS_NO, TF_PSS.PRD_NAME, TF_PSS.QTY, TF_PSS.UP, TF_PSS.AMTN_NET, TF_PSS.TAX, MF_PSS.INV_NO, BG_CUST.SNM FROM MF_PSS INNER JOIN TF_PSS ON MF_PSS.PS_NO = TF_PSS.PS_NO INNER JOIN BG_CUST ON MF_PSS.CUS_NO = BG_CUST.CustNumber WHERE (MF_PSS.PS_ID = 'SA ') AND MF_PSS.PS_DD BETWEEN ' "+ startDate + " ' AND ' "+ endDate + " ' AND MF_PSS.CUS_NO IN (SELECT CUS_NO FROM BG_Cust_Print) AND MF_PSS.CUS_NO NOT IN (SELECT CUS_NO FROM BG_Cust_UnPrint) ";
SqlCommand cmd = new SqlCommand(SQL_SELECT_SA,conn);
SqlDataReader rdr = cmd.ExecuteReader();
int i = 0;
while(rdr.Read())
{
item = one.Arr[i];//出错行;
item.PsId = rdr.GetString(0);
item.CusNo = rdr.GetString(1);
item.PsNo = rdr.GetString(2);
item.OsNo = rdr.GetString(3);
item.PrdName = rdr.GetString(4);
item.Qty = rdr.GetString(5);
item.Up = rdr.GetString(6);
item.AmtnNet = rdr.GetS