Spaces in column name

  • Thread starter Thread starter Steven Smith
  • Start date Start date
S

Steven Smith

When this event is triggered the following exception
error occurs:
'System.Data.SyntaxErrorException'
Missing operand after 'of' operator.

So presumably it doesn't like the spaces in the column
name, is there any way of temporarily renaming the column
for this procedure, or will I have to rename the column
in the database, regenerate datasets and rebind the grid ?


\\\
Dim strThisWeeksOrders As String = Today.ToOADate - 7

Me.OrdersDataGrid.DataSource = DataView1
DataView1.RowFilter = "Date of Order = strThisWeeksOrders"
///

Thanks in advance

Regards Steve
 
Steven Smith said:
When this event is triggered the following exception
error occurs:
'System.Data.SyntaxErrorException'
Missing operand after 'of' operator.

So presumably it doesn't like the spaces in the column
name, is there any way of temporarily renaming the column
for this procedure, or will I have to rename the column
in the database, regenerate datasets and rebind the grid ?


\\\
Dim strThisWeeksOrders As String = Today.ToOADate - 7

You should enable Option Strict.
Me.OrdersDataGrid.DataSource = DataView1
DataView1.RowFilter = "Date of Order = strThisWeeksOrders"
///

Thanks in advance

Regards Steve

Untested:
DataView1.RowFilter = "[Date of Order] = " & strThisWeeksOrders


Why did you declare "Date of Order" as Double?
 
Hi Steven,

That date of Order has to be an datacolumn expression this one I could not
find.

Is there not a just a date column in order and is than

"MyOrderDate = strWeekorders" than not sufficient?

Cor
 
.. . .
So presumably it doesn't like the spaces in the column
name, is there any way of temporarily renaming the column
for this procedure, or will I have to rename the column
in the database, regenerate datasets and rebind the grid ?

I would say rename the column. Spaces in column names are a
seriously bad idea, for this reason above all. You /can/ get round
it for /some/ databases by putting square braces around the name,
as in

DataView1.RowFilter = _
"[Date of Order] = '" & strThisWeeksOrders & "' "

(Note syntax change to embed variable into SQL string)
but, personally, I'd no. You might remember to do this but you can
bet the next person who goes anywhere near this table will forget.

HTH,
Phill W.
 
Not quite sure all this databinding is unchartered
teritory for me and I keep getting lost and confused

all I want to do is take Todays date minus 7 days, store
this in a variable and use this value when applying my
filter

thanks in advance

regards steve
 
Yeah I picked up on it right away but I've been
explicitly told THE ERM IS NOT TO BE MODIFIED under any
circumstances, presumably someone's idea of a joke :)

Steve
 
Just as a test this works fine

\\\
Dim strThisWeeksOrders As String = "10\10\2003"

Me.OrdersDataGrid.DataSource = DataView1
DataView1.RowFilter = "[Date of Order] >= '" &
strThisWeeksOrders & "'"
///


so does this which fine for todays orders:

\\\
Dim dateTodaysOrders As Date = Today

Me.OrdersDataGrid.DataSource = DataView1
DataView1.RowFilter = "[Date of Order] >= '" &
dateTodaysOrders & "'"
///

but still can't find away to take 7 days away from 'Today'
I suppose I could just add a datetime picker use it's
text property and make it 'Visible = False' but there has
to be a better way


Steve
 
Steven Smith said:
Not quite sure all this databinding is unchartered
teritory for me and I keep getting lost and confused

all I want to do is take Todays date minus 7 days, store
this in a variable and use this value when applying my
filter


I assume that the type of "date of order" is Date. Subtract seven days from
today:

dim d as date
d = date.today.adddays(-7)


As the Rowfilter of a dataview is a string, convert d to a string before
building the filter string.

dataview1.rowfilter = "[date of order] = " & d.tostring("\#M\/d\/yyyy\#")

Details for rowfilter property: <F1> ;-) There's a link to
Datcolum.Expression containing the syntax description.
 
The DateTimePicker is obviously a much better choice this
will let the user view orders dynamically from any date
they choose

Thanks for everyones help on the subject
Much appreciated

Regards Steve
 
Hi Steven,

But the first sentence of my message stays,

I could not find any "date of Order" that looks as a datacolumn expression

Or maybe I did not see it?

Cor
 
Back
Top