|
-
May 24th, 2005, 12:08 AM
#1
Thread Starter
Addicted Member
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.
-
May 24th, 2005, 05:34 AM
#2
Re: Plzzzzzzz Help Me
 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?
-
May 24th, 2005, 06:05 AM
#3
Thread Starter
Addicted Member
Re: Plzzzzzzz Help Me
how we add data in datagrid
-
May 24th, 2005, 08:39 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|