DATA ROW AS A PARAMETER

715 views
Skip to first unread message

DotnetBeginner

unread,
Aug 1, 2009, 7:46:28 PM8/1/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi Guys,

Pleas help out, I know this is very small , but i am not getting.I am
trying to call a method with data row as a parameter.


Here is the code.


I am calling the method sendShippedEmail(DataRow rs)in this
program.cs but i dont know how to pass that datarow rs while calling
this method in program.cs



---------------PROGRAM.CS---------------------------

using System;

using System.Collections.Generic;

using System.Text;

using System.Data.SqlClient;

using System.Data;



namespace ShippingApp

{

class Program

{

static void Main(string[] args)

{

try

{

DataRow ds = new



ShippingUtility.sendShippedEmail(------------
HERE IS MY DOUBT HELP ME----------------- );

}

catch(Exception ex)

{

ErrorHelper.logErrorToEventlog(ex, "Main Error!!!!");

}

}

}

}


-----------------------------SHIPPING APPLICATION--------------------

namespace ShippingApp

{

public class ShippingUtility

{

public static void processsShippingInfoAPA()

{

// Program starts here

//string xmlFileUrl = "";

int customerno = int.Parse
( Properties.Settings.Default.APACustomerNo);

//customerno = int.Parse(ConfigurationManager.AppSettings
["APACustomerNo"]);

// DateTime tdate = DateTime.Today.AddDays(-34).Date;

DateTime tdate = DateTime.Today.AddDays(-1).Date;

DataSet ds = AOD.Shipments.getShippedOrders(customerno,
tdate);

if (ds != null)

{

foreach (DataRow rs in ds.Tables[0].Rows)

{

ShippingUtility.sendShippedEmail(rs);

}

}

}


------



public static void sendShippedEmail(DataRow rs)

{

try

{

//get updated shipped xml

string xmlFileUrl =
Properties.Settings.Default.BackUPShippingFilePath + rs["CustOrderID"]
+ "_shipped.xml";



XmlTextReader reader = null;

reader = new XmlTextReader(xmlFileUrl);

XmlDocument myXmlDoc = new XmlDocument();

myXmlDoc.Load(reader);



//Call method to send shipping email

AOD.MailHelper.sendShippedEmail(myXmlDoc,
Properties.Settings.Default.emailTemplatePath, rs);

AOD.Shipments.setOrderStatusToConfirmedEmailSent(rs);

Console.Write("Shipping was sucessful");

}

catch(Exception ex)

{

ErrorHelper.logErrorToEventlog(ex,
"ShippingUtility.sendShippedEmail");

}

}

}

}



-

Benj Nunez

unread,
Aug 3, 2009, 5:17:22 AM8/3/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi! Normally I would extract what the DataRow holds, and not pass the
whole Datarow object completely to another method.

It goes something like this:

DataRow Row;
Row = (DataRow) ds.Tables[0].Rows[0];

String field1 = Row["MY_TABLEFIELD1"].ToString();
String field2 = Row["MY_TABLEFIELD2"].ToString();

...
ShippingUtility.sendShippedEmail(field1); // or field2, whatever
field that you want processed.



Cheers!


Benj
Message has been deleted

Cybosoft Advertising Solutions

unread,
Aug 3, 2009, 2:18:24 AM8/3/09
to DotNetDe...@googlegroups.com, sush...@gmail.com

Why are you using datarow as parameter just pass a single string. Just
create a composite string which is combination of many string as you
want separated by a special character. Where you want to extract your
data just use [string].split('separator character') and catch the
output in a string array and use the array as you want. As you are
beginner it will be more easy for you.
Just try. If you are
still getting problem then mail me again i will send you an example.
Best of Luck.

Man Vuong Ha Thanh

unread,
Aug 2, 2009, 10:14:56 AM8/2/09
to DotNetDe...@googlegroups.com
I don't understand your intention, but I think you should do some thing as you do in the method 'processsShippingInfoAPA()':
- Get a DataSet:  DataSet ds = ....
- Then, walk through the DataSet to get each DataRow:

        foreach (DataRow rs in ds.Tables[0].Rows)
       {....}
--
kidVN

Cerebrus

unread,
Aug 3, 2009, 9:27:43 AM8/3/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
It appears to me that you need to call processsShippingInfoAPA() and
not sendShippedEmail() in the Main() function.

Cerebrus

unread,
Aug 3, 2009, 9:28:14 AM8/3/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Good advice, that! :-)

Cerebrus

unread,
Aug 3, 2009, 9:31:47 AM8/3/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I guess by that logic, the OP should use a database table with a
single column in which all values are concatenated based on a
separator ?

Is that the kind of coding practice that you impart to beginners ?

On Aug 3, 11:18 am, Cybosoft Advertising Solutions
<cybos...@gmail.com> wrote:
>
> Why are you using datarow as parameter just pass a single string. Just
> create a composite  string which is combination of many string as you
> want separated by a special character. Where you want to extract your
> data just use [string].split('separator character') and catch the
> output in a string array and use the array as you want. As you are
> beginner it will be more easy for you.
>                                              Just try. If you are
> still getting problem then mail me again i will send you an example.
>                                                 Best of Luck.- Hide quoted text -
>
> - Show quoted text -

sushma sushma

unread,
Aug 3, 2009, 3:06:40 PM8/3/09
to DotNetDe...@googlegroups.com
Hey yes it is i did that thanks, i got it
--
Thanks,

Sushma

Email: sush...@gmail.com

Benj Nunez

unread,
Aug 4, 2009, 4:38:58 AM8/4/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
You're welcome.
> Email: sushma...@gmail.com

Benj Nunez

unread,
Aug 4, 2009, 4:41:28 AM8/4/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Thank you.

Cybosoft Advertising Solutions

unread,
Aug 3, 2009, 1:20:25 PM8/3/09
to DotNetDe...@googlegroups.com

I think string conversion is more easy so i suggested this method for begginers.

Cybosoft Advertising Solutions

unread,
Aug 4, 2009, 2:30:51 AM8/4/09
to DotNetDe...@googlegroups.com, sush...@gmail.com

May I know, Tumne kya kia?

Brandon Betances

unread,
Aug 4, 2009, 1:43:41 PM8/4/09
to DotNetDe...@googlegroups.com
Uninstall the old one and install the new one? Sounds pretty straight forward to me.
Reply all
Reply to author
Forward
0 new messages