我晕~~
怎么没人来看啊
都怎么了啊我有写了一个调试用的函数啊
如下;
()
我写了个函数如下
public void show_row()
{
int     count,row_count;
string  str;
count = order.Tables["Table"].Rows.Count ;
row_count = order.Tables["Table"].Columns.Count;
for ( int i=0; i<count; i++)
{
DataRow row = order.Tables["Table"].Rows[i];
for(int m=0; m<row_count; m++)
{
str = Convert.ToString(row[m]);
}
当m=5的时候啊
发现在FILL之后那个str还是没值啊
是什么原因呢?

解决方案 »

  1.   

    protected void BuildTable()
    {
    //创建数据库
    order    = new DataSet("OrderData");
    //创建表
    table    = new DataTable("Table");
    //middle   = new DataTable("middle");
    //tail     = new DataTable("Tail");
    //创建例
    System.Data.DataColumn  Provide    = new DataColumn("provide",typeof(System.String));
    System.Data.DataColumn  Datetime   = new DataColumn("datatime",typeof(System.DateTime));
    System.Data.DataColumn  OrderID    = new DataColumn("orderid",typeof(System.Int32));
    System.Data.DataColumn  Warename   = new DataColumn("warename",typeof(System.String ));
    System.Data.DataColumn  Unit       = new DataColumn("unit",typeof(System.String));
    System.Data.DataColumn  Count      = new DataColumn("count",typeof(System.Int32));
    System.Data.DataColumn  Unitprice  = new DataColumn("unitprice",typeof(System.Double ));
    System.Data.DataColumn  Sum        = new DataColumn("sum",typeof(System.Double));
    System.Data.DataColumn  Re     = new DataColumn("re",typeof(System.String));
    System.Data.DataColumn  Operation  = new DataColumn("operation",typeof(System.String));
    //把例添加到表中
    table.Columns.Add(OrderID);
    table.Columns.Add(Provide);
    table.Columns.Add(Datetime);
    table.Columns.Add(Warename);
    table.Columns.Add(Unit);
    table.Columns.Add(Count);
    table.Columns.Add(Unitprice);
    table.Columns.Add(Sum);
    table.Columns.Add(Re);
    table.Columns.Add(Operation);
    //设主键
    //System.Data.DataColumn[ ]  Pk = new DataColumn[ ]{OrderID};
    //table.PrimaryKey = Pk;
    //把表添加到内存数据库
    order.Tables.Add(table);
    }     
    }
    }public String Str_err
    {
    get { return Str_error; }
    set { Str_err = value;}
    } public DataRow row
    {
    get { return Ora_row; }
    set { Ora_row = value;}
    } public string[] Str_row
    {
    get { return Ora_arr;}
    set{ Ora_arr = value;}
    } public Order_table()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    //
    BuildTable();
    BuildOrderTable();
    //Connection();
    FillOrder();
    } protected void BuildOrderTable()
    {
    //添加例
    System.Data.DataColumn  Deldatetime = new DataColumn("deldatetime",typeof(System.DateTime));
    System.Data.DataColumn  Deladr      = new DataColumn("deladr",typeof(System.String ));
    System.Data.DataColumn  Tax         = new DataColumn("tax",typeof(System.Double ));
    //添加到表中去
    order.Tables[0].Columns.Add(Deldatetime);
    order.Tables[0].Columns.Add(Deladr);
    order.Tables[0].Columns.Add(Tax);
    }
            
    public void FillOrder()
    {
    string Str_com = "select  OrderID, Provide, DateTime, WareName, Unit, Counts, UnitPrice, Sums, Re, Operation, DelDateTime, DelAdr, Tax from Orders";
    Str_con = "workstation id=\"CQRQ-228E08064B\";packet size=4096;user id=order;password=\"42964304\";data source=\"CQRQ" +
    "-228E08064B\";persist security info=False;initial catalog=gpd";
    Ora_con = new SqlConnection(Str_con);
    Ora_con.Open();
    Ora_com = new SqlCommand(Str_con,Ora_con);
    Ora_ada = new SqlDataAdapter(Str_com,Ora_con);
    try
    {
    Ora_ada.Fill(order,"Table");
    Ora_con.Close();
    }
    catch (Exception ev)
    {
    Str_err = ev.Message ;
    }
    show_row();
    }
      

  2.   

    public void StringToRow()
    {
    DataRow curRow = order.Tables["Table"].NewRow();
    //curRow["orderid"]        = Ora_arr[0];
    curRow["provide"]        = Ora_arr[0];
    curRow["datetime"]       = Ora_arr[1];
    curRow["warename"]       = Ora_arr[2];
    curRow["unit"]           = Ora_arr[3];
    curRow["count"]          = Ora_arr[4];
    curRow["unitprice"]      = Ora_arr[5];
    curRow["sum"]            = Ora_arr[6];
    curRow["re"]         = Ora_arr[7];
    curRow["operation"]      = Ora_arr[8];
    curRow["deldatetime"]    = Ora_arr[9];
    curRow["deladr"]         = Ora_arr[10];
    curRow["tax"]            = Ora_arr[11];
    order.Tables["Table"].Rows.Add(curRow);
    } public void RowtoString()
    {
    DataRow[] curRow = order.Tables["Table"].Select("orderid =" + Convert.ToString(id));
    Ora_arr  = new string[] {   
    Convert.ToString(curRow[0]["provide"]),
    Convert.ToString(curRow[0]["datetime"]),
    Convert.ToString(curRow[0]["warename"]),      
    Convert.ToString(curRow[0]["unit"]),  
    Convert.ToString(curRow[0]["count"]),    
    Convert.ToString(curRow[0]["unitprice"]),
    Convert.ToString(curRow[0]["re"]),
    Convert.ToString(curRow[0]["sum"]),    
    Convert.ToString(curRow[0]["operation"]),      
    Convert.ToString(curRow[0]["deldatetime"]),  
    Convert.ToString(curRow[0]["deladr"]),
    Convert.ToString(curRow[0]["tax"])
    };
    //string a = Convert.ToString(curRow[0]["count"]);
    }
               
    public void show_row()
    {
    int     count,row_count;
    string  str;
    count = order.Tables["Table"].Rows.Count ;
    row_count = order.Tables["Table"].Columns.Count;
    for ( int i=0; i<count; i++)
    {
    DataRow row = order.Tables["Table"].Rows[i];
    for(int m=0; m<row_count; m++)
    {
    str = Convert.ToString(row[m]);
    }
    }
    }