By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,939 Members | 1,638 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,939 IT Pros & Developers. It's quick & easy.

Spaces in column name

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
11 Replies


P: n/a
"Steven Smith" <an*******@discussions.microsoft.com> schrieb
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?

--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #2

P: n/a
Cor
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
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

Nov 20 '05 #3

P: n/a
Cor
No No No I saw Armins answer
"MyOrderDate = strWeekorders" than not sufficient? "MyOrderDate = " & strWeekorders than not sufficient?

Sorry did not look well

Cor
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
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


Nov 20 '05 #4

P: n/a
"Steven Smith" <an*******@discussions.microsoft.com> wrote in message
news:0a****************************@phx.gbl...
.. . .
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.
Nov 20 '05 #5

P: n/a
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
Nov 20 '05 #6

P: n/a
:)
Nov 20 '05 #7

P: n/a
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
Nov 20 '05 #8

P: n/a
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
Nov 20 '05 #9

P: n/a
"Steven Smith" <an*******@discussions.microsoft.com> schrieb
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.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #10

P: n/a
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
Nov 20 '05 #11

P: n/a
Cor
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
Nov 20 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.