PC Review


Reply
Thread Tools Rate Thread

Datatable.Compute and Sorting

 
 
scorpion53061
Guest
Posts: n/a
 
      10th May 2004
Can I use this to sort a datatable or can you suggest another way to sort it
without using a dataview? I have a situation where I need to do this without
a dataview due to other facets it will affect within my application.

When I try

opends1.Tables(0).Compute("ORDER by " & sortterm & "","") it says I am
missing the operand after "by".


 
Reply With Quote
 
 
 
 
scorpion53061
Guest
Posts: n/a
 
      10th May 2004
Never mind.

Figured it out.

"scorpion53061" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Can I use this to sort a datatable or can you suggest another way to sort

it
> without using a dataview? I have a situation where I need to do this

without
> a dataview due to other facets it will affect within my application.
>
> When I try
>
> opends1.Tables(0).Compute("ORDER by " & sortterm & "","") it says I am
> missing the operand after "by".
>
>



 
Reply With Quote
 
William Ryan eMVP
Guest
Posts: n/a
 
      10th May 2004
Hi Scorp:

Being that the dataview is like Duct Tape (you can do anything with it) to
me, I was wondering what the scenario is, just out of curiousity.

Thanks,

Bill


www.devbuzz.com
www.knowdotnet.com

"scorpion53061" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Can I use this to sort a datatable or can you suggest another way to sort

it
> without using a dataview? I have a situation where I need to do this

without
> a dataview due to other facets it will affect within my application.
>
> When I try
>
> opends1.Tables(0).Compute("ORDER by " & sortterm & "","") it says I am
> missing the operand after "by".
>
>



 
Reply With Quote
 
scorpion53061
Guest
Posts: n/a
 
      10th May 2004
Sure no problem.

The problem is that this is a globally declared dataset that needed the data
in the sort order for the report writing functions in another module. I
could have used the dataview but then when they went to write the report the
order would be wrong. If I change to a globally declared dataview I was
concerned what effect it would have on my excel and word reports (I have
never tried to write a dataview to an excel spreadsheet so it may be
possible).

Another problem has been encountered that my interest you.

DATEOR is a date column in the dataset. The task is to format the column to
get the (12:00:00) time off and color the box is the value of backorders > 0
and days > 90.

However though it is appearing as I wanted it too and sorting as I requested
it to, the yellow has been lost.

Can you suggest what I am doing wrong?

I have a class for my datagrid called ClassDatagridFormat

one if ...Then procedure says:

If Me.MappingName = "DATEOR" Then
Dim ObjVal As Object
ObjVal = Me.GetColumnValueAtRow(curmngrSrc, RowNumber)
Dim days As Integer
Dim cellValue As String
cellValue = CType(ObjVal, Date).ToShortDateString
days = DateDiff(DateInterval.Day, CDate(cellValue),
CDate(timeofrecord))
If days >= 90 And backorders = 0 Then
BackColorBrush = System.Drawing.Brushes.Yellow
End If
If days >= 90 And backorders > 0 Then
BackColorBrush = System.Drawing.Brushes.White
End If
If days < 90 Then
BackColorBrush = System.Drawing.Brushes.White
End If
ForeColorBrush = Brushes.Black
MyBase.Paint(graph, rectbounds, curmngrSrc, RowNumber, _
BackColorBrush, ForeColorBrush, AlignmentLeft)
'DataAlignment = HorizontalAlignment.Center
graph.FillRectangle(BackColorBrush, rectbounds)
'draw the value
Dim s As String = Me.GetColumnValueAtRow([curmngrSrc],
RowNumber).ToString()
Dim r As New RectangleF(rectbounds.X, rectbounds.Y,
rectbounds.Width, rectbounds.Height)
graph.DrawString(s, MyBase.TextBox.Font, ForeColorBrush, r,
mDrawTxt)
Me.TextBox.ReadOnly = True
mTxtAlign = HorizontalAlignment.Left
mDrawTxt.LineAlignment = StringAlignment.Center
'Exit Sub
End If

The call in the form to this Class is :

Dim myCurrencyManger As CurrencyManager = CType(Me.BindingContext(opends1),
CurrencyManager)
Dim proprtyDescriptorName As PropertyDescriptor =
myCurrencyManger.GetItemProperties()(opends1.Tables(0).TableName)
Dim myDateDescriptor As PropertyDescriptor =
myCurrencyManger.GetItemProperties()("DATEOR")
Dim myDateStyle = New DataGridTextBoxColumn(myDateDescriptor, "G")
myDateStyle.MappingName = "DATEOR"
myDateStyle.HeaderText = "DATE"
myDateStyle.Width = 75
myDateStyle.Format = "d"

By the way, are you ready for the "article"?

The problem is that this dataset is declared globally
"William Ryan eMVP" <(E-Mail Removed)> wrote in message
news:ey%(E-Mail Removed)...
> Hi Scorp:
>
> Being that the dataview is like Duct Tape (you can do anything with it) to
> me, I was wondering what the scenario is, just out of curiousity.
>
> Thanks,
>
> Bill
>
>
> www.devbuzz.com
> www.knowdotnet.com
>
> "scorpion53061" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Can I use this to sort a datatable or can you suggest another way to

sort
> it
> > without using a dataview? I have a situation where I need to do this

> without
> > a dataview due to other facets it will affect within my application.
> >
> > When I try
> >
> > opends1.Tables(0).Compute("ORDER by " & sortterm & "","") it says I am
> > missing the operand after "by".
> >
> >

>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      10th May 2004
Hi Scorpion,

What you can do I think is this in completly pseudo

Make a dataview from your table
Make a clone from your table
Make a loop through your dataview to your new datatable something as this
(also pseudo)
for i as integer = 0 to dataview.rows.count - 1
dim dr as datarow = dataview.table.newrow
for y as integer = 0 to dataview.rows(i).items.count - 1
' this to prevent keysproblems
dr(y) = dv(i)(y)
next
newdatatable.add(dr)
next

Just as an idea.

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
datatable.compute Chuck Hecht Microsoft Dot NET Compact Framework 1 28th Aug 2007 03:45 AM
DataTable.Compute() question SpaceMarine Microsoft Dot NET Framework 5 22nd Aug 2007 08:41 AM
DataTable.Compute() question SpaceMarine Microsoft ADO .NET 5 22nd Aug 2007 08:41 AM
DataTable Compute Method =?Utf-8?B?QW5kcmVpd2lk?= Microsoft ADO .NET 1 8th Nov 2005 07:01 PM
datatable.compute method =?Utf-8?B?RGF2aWQgQW5kZXJzb24=?= Microsoft Dot NET 1 8th Jun 2005 11:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:17 PM.