Results 1 to 4 of 4

Thread: Plzzzzzzz Help Me

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    141

    Angry Plzzzzzzz Help Me

    Code:
    internal void LoadMachineData(DateTime CurDate,DataSet Dset)
    {	    	
    if  (G1.cn.State == ConnectionState.Closed)
    {
    	G1.ConnectDB();
    }
    int[] MCNO = new int[Dset.Tables["ComberMachine"].Rows.Count];
    float[] FRollDia = new float[Dset.Tables["ComberMachine"].Rows.Count];
    cmSQL = new SqlCommand("select * from PD_ComMachines",G1.cn);
    SQLDR = cmSQL.ExecuteReader();					
    int i=0;
    while (SQLDR.Read())
    {								
    MCNO[i] = int.Parse(SQLDR["MachineNo"].ToString());
    FRollDia[i] = int.Parse(SQLDR["FRollDia"].ToString());
    i = i+1;
    }						
    SQLDR.Close();
    cmSQL.Dispose();				
    G1.CloseConnection();
    i =0;
    
    // Loop run and call Fill Grid Method   
    for (i=0;i<=MCNO.Length-1;i++)
    {				
        FillGrid(MCNO[i],FRollDia[i],CurDate);			
    }
    }
    
    For Loop run 10 times and each time Procedure return one value 
    how we fill dataGird when Stored Prodcedure retruen one value each time
    
    internal void FillGrid(int MachineNO,float FDia,DateTime CurDate)
    {
    	try
    	{			
    SqlCommand cmdFill = new SqlCommand("CurrentComberMachineConfig",G1.cn);				
    cmdFill.CommandType=CommandType.StoredProcedure;	cmdFill.Parameters.Add("@machNo", SqlDbType.Int);
    	cmdFill.Parameters["@machNo"].Value = MachineNO;
    	cmdFill.Parameters["@machNo"].Direction = ParameterDirection.Input;
    
    cmdFill.Parameters.Add("@CODate", SqlDbType.DateTime);
    				cmdFill.Parameters["@CODate"].Value = DateTime.Parse(string.Format("{0:dd/MM/yyyy}",CurDate));
    				cmdFill.Parameters["@CODate"].Direction = ParameterDirection.Input;
    				
    cmdFill.Parameters.Add("@FRollDia", SqlDbType.Float);
    cmdFill.Parameters["@FRollDia"].Value = FDia;
    cmdFill.Parameters["@FRollDia"].Direction = ParameterDirection.Input;
    
    cmdFill.Parameters.Add("@CODateo", SqlDbType.VarChar,20);
    cmdFill.Parameters["@CODateo"].Direction = ParameterDirection.Output;
    				
    cmdFill.Parameters.Add("@coID", SqlDbType.Char,5);
    cmdFill.Parameters["@coID"].Direction = ParameterDirection.Output;
    
    cmdFill.Parameters.Add("@HanksSliver", SqlDbType.Float);
    cmdFill.Parameters["@HanksSliver"].Direction = ParameterDirection.Output;
    
    cmdFill.Parameters.Add("@COTime", SqlDbType.VarChar,20);
    cmdFill.Parameters["@COTime"].Direction = ParameterDirection.Output;
    				
    if  (G1.cn.State == ConnectionState.Closed)
          {
    	G1.ConnectDB();
          }								
    cmdFill.ExecuteNonQuery();				
    // Retrive result  from stored procedure
    
    CODate = (string)cmdFill.Parameters["@CODateo"].ToString();
    COID = (string)cmdFill.Parameters["@coID"].ToString();
    HanksSliver = (double)cmdFill.Parameters["@HanksSliver"].Value;
    COTime = (string)cmdFill.Parameters["@COTime"].ToString();
    Edit: Added code tags for clarity - Hack
    Last edited by Hack; May 24th, 2005 at 05:33 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Plzzzzzzz Help Me

    Quote Originally Posted by Waseemalisyed
    For Loop run 10 times and each time Procedure return one value how we fill dataGird when Stored Prodcedure retruen one value each time
    Is this the question?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2005
    Location
    Canada
    Posts
    141

    Angry Re: Plzzzzzzz Help Me

    how we add data in datagrid

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Plzzzzzzz Help Me

    Instantiate a new datatable and add each value returned from the SP to the datatable. You can then bind the datagrid to the datatable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width