Showing posts with label returns. Show all posts
Showing posts with label returns. Show all posts

Saturday, March 31, 2012

String to Object?

Hi:

Can I convert a string to an object?

In my system I have the following:

Document.Title.Contains("Sony Camera")

The above returns an object of type Criterion, however, it will be saved in database,

when i read the above line as string, i want to make it an object of type Criterion, is this possible?

thank you.

Hi

(objectName) Document.Title.Contains("Sony Camera")

or

object.parse(Document.Title.Contains("Sony Camera"));


Hi

Thanks for the reply.

Don't I need any reflection? Just guessing.

Thanks,

Wednesday, March 28, 2012

String.Compare\Browser Detect\VB

VS.NET 2002\Web\VB

This is what Request.UserAgent returns for Mozilla Firebird:

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
Firebird/0.7

Is there any reason why this shouldn't work to identify a visitor using that
browser?

If String.Compare(Request.UserAgent, "firebird", True) = True Then
[code]
End If

Using Mozilla Firebird, it jumps right over it. As a test, I replaced
"firebird" with "msie," and it catches the IE browser with no problem. So
why not firebird?

I can't use browser name or browser type because it returns Netscape, not
Firebird.

Thanks,
GeorgeI think you want String.IndexOf, not String.Compare.
http://msdn.microsoft.com/library/d...ndexoftopic.asp

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"George" <--@.--.--> wrote in message
news:1inVb.83$fV5.401@.bgtnsc04-news.ops.worldnet.att.net...
> VS.NET 2002\Web\VB
> This is what Request.UserAgent returns for Mozilla Firebird:
> Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
> Firebird/0.7
> Is there any reason why this shouldn't work to identify a visitor using
that
> browser?
> If String.Compare(Request.UserAgent, "firebird", True) = True Then
> [code]
> End If
> Using Mozilla Firebird, it jumps right over it. As a test, I replaced
> "firebird" with "msie," and it catches the IE browser with no problem. So
> why not firebird?
> I can't use browser name or browser type because it returns Netscape, not
> Firebird.
> Thanks,
> George
Thanks, Eric, that did work. At a loss as to why the other one didn't work,
though.

George

"Eric Lawrence [MSFT]" <e_lawrence@.hotmail.com> wrote in message
news:O5DgI$i7DHA.1052@.TK2MSFTNGP12.phx.gbl...
> I think you want String.IndexOf, not String.Compare.
http://msdn.microsoft.com/library/d...ndexoftopic.asp
> --
> Thanks,
> Eric Lawrence
> Program Manager
> Assistance and Worldwide Services
> This posting is provided "AS IS" with no warranties, and confers no
rights.
>
>
> "George" <--@.--.--> wrote in message
> news:1inVb.83$fV5.401@.bgtnsc04-news.ops.worldnet.att.net...
> > VS.NET 2002\Web\VB
> > This is what Request.UserAgent returns for Mozilla Firebird:
> > Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
> > Firebird/0.7
> > Is there any reason why this shouldn't work to identify a visitor using
> that
> > browser?
> > If String.Compare(Request.UserAgent, "firebird", True) = True Then
> > [code]
> > End If
> > Using Mozilla Firebird, it jumps right over it. As a test, I replaced
> > "firebird" with "msie," and it catches the IE browser with no problem.
So
> > why not firebird?
> > I can't use browser name or browser type because it returns Netscape,
not
> > Firebird.
> > Thanks,
> > George
String.Compare looks to see if the exact string matches (with or without the
case-sensitive flag).

The string "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5)
Gecko/20031007 Firebird/0.7" is not an exact match for the string
"firebird".

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"George" <--@.--.--> wrote in message
news:uDwVb.199534$6y6.4020354@.bgtnsc05-news.ops.worldnet.att.net...
> Thanks, Eric, that did work. At a loss as to why the other one didn't
work,
> though.
> George
>
> "Eric Lawrence [MSFT]" <e_lawrence@.hotmail.com> wrote in message
> news:O5DgI$i7DHA.1052@.TK2MSFTNGP12.phx.gbl...
> > I think you want String.IndexOf, not String.Compare.
http://msdn.microsoft.com/library/d...ndexoftopic.asp
> > --
> > Thanks,
> > Eric Lawrence
> > Program Manager
> > Assistance and Worldwide Services
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > "George" <--@.--.--> wrote in message
> > news:1inVb.83$fV5.401@.bgtnsc04-news.ops.worldnet.att.net...
> > > VS.NET 2002\Web\VB
> > > > This is what Request.UserAgent returns for Mozilla Firebird:
> > > > Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007
> > > Firebird/0.7
> > > > Is there any reason why this shouldn't work to identify a visitor
using
> > that
> > > browser?
> > > > If String.Compare(Request.UserAgent, "firebird", True) = True Then
> > > [code]
> > > End If
> > > > Using Mozilla Firebird, it jumps right over it. As a test, I replaced
> > > "firebird" with "msie," and it catches the IE browser with no problem.
> So
> > > why not firebird?
> > > > I can't use browser name or browser type because it returns Netscape,
> not
> > > Firebird.
> > > > Thanks,
> > > George
> > >

Monday, March 26, 2012

String/Number manip.

In the following line:
txtWage.Text = "$" & Trim(dataReader.GetValue(9).ToString)

It returns $20.0000 I only want it to return back $20.00 -- every search I've done in string manip. has shown me zilch.

Any suggestions?

txtWage.Text = Format(CDbl(Trim(dataReader.GetValue(9).ToString)), "currency")
I think you can use String.Format also to do the same thing, with the format of {0:c}

Thursday, March 22, 2012

Strongly Typed Collections

I'm writing a web service that I want to return a strongly typed collection.
If I inherit System.collections.generic.list(of T) it returns an ArrayOfT.
If I inherit CollectionsBase, it also returns an ArrayOf. I want the root
xml element to just be of the class itself (if that makes any sense). Is
this even possible? What do I need to inherit?
If you want a strong object/collection on the outside world (of a web
service)...then the client needs to know something about some kind of strong
collection.
..
Take a look here:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!158.entry
I have a IZebraCollection......which the service and the host know about.
Its WCF, but WCF can be exposed as a webservice.
..
"Dave T" <DaveT@.discussions.microsoft.com> wrote in message
news:A1A6AA44-6974-4B5C-9C11-795D570F46A7@.microsoft.com...
> I'm writing a web service that I want to return a strongly typed
> collection.
> If I inherit System.collections.generic.list(of T) it returns an ArrayOfT.
> If I inherit CollectionsBase, it also returns an ArrayOf. I want the root
> xml element to just be of the class itself (if that makes any sense). Is
> this even possible? What do I need to inherit?

Strongly typed datasets and nested repeaters

I have a strongly typed dataset that returns two tables - "items" and
"itemdetails". In the strongly-typed dataset designer, I've created a link
(relationship) between the two tables based on a foreign key.

I want to put them into a nested repeater, but I'm having problems finding a
"nice" way of doing it.

Can someone please point me in the direction of a tutorial or best practice
to achieve this?

Thanks in advance,

Duncanassign the "Items" table to the outter repeater, then in the
OnItemDataBound event handler:

switch (e.Item.ItemType){
case ListItemType.Item: case ListItemType.AlternatingItem:
Repeater ir = e.Item.FindControl("rptInnerRepeater")
ir.DataSource =
((DataRowView)e.Item.DataItem).CreateChildView("ItemDetailDataRelation");
ir.DataBind();
}

hope that helps
Thanks for your reply; I saw this example on the web, but I'm unsure where
the ItemDetailDataRelation comes from. I tried all the relationship names
that were in the strongly-typed dataset designer, but they gave an error.

I got the impression that if you were doing it between two datatables, that
would be the name of the Relations.Add(... but I couldn't seem to create a
programatic relationship between two fields in a strongly typed dataset.

Duncan

"bfking" <bfking@.gmail.com> wrote in message
news:1112879887.227421.298170@.g14g2000cwa.googlegr oups.com...
> assign the "Items" table to the outter repeater, then in the
> OnItemDataBound event handler:
> switch (e.Item.ItemType){
> case ListItemType.Item: case ListItemType.AlternatingItem:
> Repeater ir = e.Item.FindControl("rptInnerRepeater")
> ir.DataSource =
> ((DataRowView)e.Item.DataItem).CreateChildView("ItemDetailDataRelation");
> ir.DataBind();
> }
> hope that helps
The relation is set up in the dataset.

something like
_myDataSet.Relations.Add("Users_Results", _myDataSet.TableA.UsersNameColumn,
_myDataSet.TableB.UsersNameColumn);

where _myDataSet is your strongly typed DataSet.
in your nested Repeater you would then do something like this:

<asp:repeater id="_reportoutput" Runat="server"
...templates

//nested repeater
<asp:repeater id="_nextstuff" Runat="server" DataSource='<%#
GetChildRelation(Container.DataItem,"Users_Results")%>'
with the following in your code behind:

public static DataView GetChildRelation(object dataItem, string relation)
{
DataRowView drv = dataItem as DataRowView;
if (drv != null)

return drv.CreateChildView(relation);
else
return null;
}

MattC
"Duncan Welch" <dunc@.ntpcl.f9.co.uk> wrote in message
news:usyUFl3OFHA.984@.TK2MSFTNGP10.phx.gbl...
> Thanks for your reply; I saw this example on the web, but I'm unsure where
> the ItemDetailDataRelation comes from. I tried all the relationship names
> that were in the strongly-typed dataset designer, but they gave an error.
> I got the impression that if you were doing it between two datatables,
> that
> would be the name of the Relations.Add(... but I couldn't seem to create a
> programatic relationship between two fields in a strongly typed dataset.
> Duncan
> "bfking" <bfking@.gmail.com> wrote in message
> news:1112879887.227421.298170@.g14g2000cwa.googlegr oups.com...
>> assign the "Items" table to the outter repeater, then in the
>> OnItemDataBound event handler:
>>
>> switch (e.Item.ItemType){
>> case ListItemType.Item: case ListItemType.AlternatingItem:
>> Repeater ir = e.Item.FindControl("rptInnerRepeater")
>> ir.DataSource =
>> ((DataRowView)e.Item.DataItem).CreateChildView("ItemDetailDataRelation");
>> ir.DataBind();
>> }
>>
>> hope that helps
>>

Strongly typed datasets and nested repeaters

I have a strongly typed dataset that returns two tables - "items" and
"itemdetails". In the strongly-typed dataset designer, I've created a link
(relationship) between the two tables based on a foreign key.
I want to put them into a nested repeater, but I'm having problems finding a
"nice" way of doing it.
Can someone please point me in the direction of a tutorial or best practice
to achieve this?
Thanks in advance,
Duncanassign the "Items" table to the outter repeater, then in the
OnItemDataBound event handler:
switch (e.Item.ItemType){
case ListItemType.Item: case ListItemType.AlternatingItem:
Repeater ir = e.Item.FindControl("rptInnerRepeater")
ir.DataSource =
((DataRowView)e.Item.DataItem).CreateChildView("ItemDetailDataRelation");
ir.DataBind();
}
hope that helps
Thanks for your reply; I saw this example on the web, but I'm unsure where
the ItemDetailDataRelation comes from. I tried all the relationship names
that were in the strongly-typed dataset designer, but they gave an error.
I got the impression that if you were doing it between two datatables, that
would be the name of the Relations.Add(... but I couldn't seem to create a
programatic relationship between two fields in a strongly typed dataset.
Duncan
"bfking" <bfking@.gmail.com> wrote in message
news:1112879887.227421.298170@.g14g2000cwa.googlegroups.com...
> assign the "Items" table to the outter repeater, then in the
> OnItemDataBound event handler:
> switch (e.Item.ItemType){
> case ListItemType.Item: case ListItemType.AlternatingItem:
> Repeater ir = e.Item.FindControl("rptInnerRepeater")
> ir.DataSource =
> ((DataRowView)e.Item.DataItem).CreateChildView("ItemDetailDataRelation");
> ir.DataBind();
> }
> hope that helps
>
The relation is set up in the dataset.
something like
_myDataSet.Relations.Add("Users_Results", _myDataSet.TableA.UsersNameColumn,
_myDataSet.TableB.UsersNameColumn);
where _myDataSet is your strongly typed DataSet.
in your nested Repeater you would then do something like this:
<asp:repeater id="_reportoutput" Runat="server">
...templates
//nested repeater
<asp:repeater id="_nextstuff" Runat="server" DataSource='<%#
GetChildRelation(Container.DataItem,"Users_Results")%>'>
with the following in your code behind:
public static DataView GetChildRelation(object dataItem, string relation)
{
DataRowView drv = dataItem as DataRowView;
if (drv != null)
return drv.CreateChildView(relation);
else
return null;
}
MattC
"Duncan Welch" <dunc@.ntpcl.f9.co.uk> wrote in message
news:usyUFl3OFHA.984@.TK2MSFTNGP10.phx.gbl...
> Thanks for your reply; I saw this example on the web, but I'm unsure where
> the ItemDetailDataRelation comes from. I tried all the relationship names
> that were in the strongly-typed dataset designer, but they gave an error.
> I got the impression that if you were doing it between two datatables,
> that
> would be the name of the Relations.Add(... but I couldn't seem to create a
> programatic relationship between two fields in a strongly typed dataset.
> Duncan
> "bfking" <bfking@.gmail.com> wrote in message
> news:1112879887.227421.298170@.g14g2000cwa.googlegroups.com...
>