Showing posts with label dim. Show all posts
Showing posts with label dim. Show all posts

Saturday, March 31, 2012

sub-selecting a DataTable?

Here's an example:
Dim dsMyData As DataSet
dsMyData = CallWebService(Param1,Param2)
Dim dtUsersTable As DataTable = dsMyData.Tables("Users")
I have a Web service that fills dsMyData with a couple tables.
My question is, from dsMyData.Tables("Users"), which contains all
users, how can I create another datatable that only returns for
UserID=1?
thanks...> Dim dsMyData As DataSet
> dsMyData = CallWebService(Param1,Param2)
> Dim dtUsersTable As DataTable = dsMyData.Tables("Users")
> I have a Web service that fills dsMyData with a couple tables.
> My question is, from dsMyData.Tables("Users"), which contains all
> users, how can I create another datatable that only returns for
> UserID=1?
This may not be the easiest way, but it should work:
'line below copies structure of Users table to NewUsers table
Dim newUserTable As DataTable = dsMyData.tables("Users").Clone
'line below renames the cloned table as to avoid naming conflicts
newUsersTable.tableName = "NewUsers"
'selects users with userid=1 and imports into NewUsers table
For Each dr As DataRow In dsMyData.tables("Users").Select("UserID=1")
newUsersTable.ImportRow(dr)
Next
' adds the newUsers table to the dataset
dsMyData.Tables.Add(newUsesTable)
Hope it helps.
Jeppe Jespersen
Jeppe,
That did help.
Thank you very much.
Eych
> That did help.
> Thank you very much.
No propblemo. :-)
Jeppe

sub-selecting a DataTable?

Here's an example:

Dim dsMyData As DataSet
dsMyData = CallWebService(Param1,Param2)
Dim dtUsersTable As DataTable = dsMyData.Tables("Users")

I have a Web service that fills dsMyData with a couple tables.
My question is, from dsMyData.Tables("Users"), which contains all
users, how can I create another datatable that only returns for
UserID=1?

thanks...> Dim dsMyData As DataSet
> dsMyData = CallWebService(Param1,Param2)
> Dim dtUsersTable As DataTable = dsMyData.Tables("Users")
> I have a Web service that fills dsMyData with a couple tables.
> My question is, from dsMyData.Tables("Users"), which contains all
> users, how can I create another datatable that only returns for
> UserID=1?

This may not be the easiest way, but it should work:

'line below copies structure of Users table to NewUsers table
Dim newUserTable As DataTable = dsMyData.tables("Users").Clone

'line below renames the cloned table as to avoid naming conflicts
newUsersTable.tableName = "NewUsers"

'selects users with userid=1 and imports into NewUsers table
For Each dr As DataRow In dsMyData.tables("Users").Select("UserID=1")
newUsersTable.ImportRow(dr)
Next

' adds the newUsers table to the dataset
dsMyData.Tables.Add(newUsesTable)

Hope it helps.
Jeppe Jespersen
Jeppe,

That did help.
Thank you very much.

Eych
> That did help.
> Thank you very much.

No propblemo. :-)

Jeppe

Monday, March 26, 2012

Suggested Microsoft way

Lately I came to know that Microsoft is suggesting to go with underscore for
naming convention for variables (Am I right?).

Ex: Dim strMyName as String --> Dim str_MyName as String

Any one has any comments. Am I talking some thing does not makes sense. If
you have any URL which tells the Microsoft suggested way on coding standard
please share with me.

Thank you very much.

MarioHaven't heard that. Last I heard, MS was recommending against that
sort of overaggressive hungarian notation in favor of camelCasing and
reliance on Intellisense to remind you of types. They've also dropped
the m_'s for members in favor of a simple underscore:

Dim myName as String

Dim _myPrivateMemberVariable as Int

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
"Mario Novado" <MNovado@.hotmail.com> wrote in message
news:O6wpqACpFHA.2580@.TK2MSFTNGP09.phx.gbl...
> Lately I came to know that Microsoft is suggesting to go with underscore
> for
> naming convention for variables (Am I right?).

For readability, an "applicant_last_name" is easier to recognize than an
"ApplicantLastName".

It is also easier for disabled persons to read (Section 508 compliance). I
could be wrong on this part (s-508).

John
I found these interesting links.

Naming conventions from MSDN
http://msdn.microsoft.com/library/d...gguidelines.asp

Designing .NET class libraries: Naming Conventions (they talk about banning
the use of Hungarian notation)
http://msdn.microsoft.com/netframew...ingconventions/

MSDN link about capitalization
http://msdn.microsoft.com/library/d...ationstyles.asp

This one has a chat with Brad Abrams (sp).
http://msdn.microsoft.com/chats/tra...ven_012605.aspx

From what I've read, they are trying to de-emphasize the hungarian notation
for publicly exposed members in favour of Pascal naming (upper case and no
underscores).

Suggested Microsoft way

Lately I came to know that Microsoft is suggesting to go with underscore for
naming convention for variables (Am I right?).
Ex: Dim strMyName as String --> Dim str_MyName as String
Any one has any comments. Am I talking some thing does not makes sense. If
you have any URL which tells the Microsoft suggested way on coding standard
please share with me.
Thank you very much.
MarioHaven't heard that. Last I heard, MS was recommending against that
sort of overaggressive hungarian notation in favor of camelCasing and
reliance on Intellisense to remind you of types. They've also dropped
the m_'s for members in favor of a simple underscore:
Dim myName as String
Dim _myPrivateMemberVariable as Int
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/
"Mario Novado" <MNovado@.hotmail.com> wrote in message
news:O6wpqACpFHA.2580@.TK2MSFTNGP09.phx.gbl...
> Lately I came to know that Microsoft is suggesting to go with underscore
> for
> naming convention for variables (Am I right?).
>
For readability, an "applicant_last_name" is easier to recognize than an
"ApplicantLastName".
It is also easier for disabled persons to read (Section 508 compliance). I
could be wrong on this part (s-508).
John
I found these interesting links.
Naming conventions from MSDN
http://msdn.microsoft.com/library/d...gguidelines.asp
Designing .NET class libraries: Naming Conventions (they talk about banning
the use of Hungarian notation)
http://msdn.microsoft.com/netframew...ntion
s/
MSDN link about capitalization
http://msdn.microsoft.com/library/d...ationstyles.asp
This one has a chat with Brad Abrams (sp).
[url]http://msdn.microsoft.com/chats/transcripts/net/design_naming_conven_012605.aspx[/
url]
From what I've read, they are trying to de-emphasize the hungarian notation
for publicly exposed members in favour of Pascal naming (upper case and no
underscores).

Saturday, March 24, 2012

Sum of XML data

I am reading an XML file and writing its contents to a Repeater control using the following code:

Dim dstTS As DataSet

dstTS = New DataSet()
dstTS.ReadXml( MapPath( "cw052004.xml" ) )

rptTS.DataSource = dstTS
rptTS.DataBind()

It works fine. However, I would also like to calculate the sum of a the "item_cost" from each node in the XML file and place it in a variable.

Can anybody suggest the best way to go about this?do some searching for examples on the itemdatabound event. this is fired everytime an item is bound and you can use this to sum up your grids and such.
Awesome, thanks!