-
Oct 21st, 2009, 07:10 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Syntax error: Missing operand after '14' operator.
Hi all,
I want to select some rows from a sql express 2005 table.
I am using this expression:
"Starttime >= " & dtpStart.Value
dtpStart is a DateTimePicker
But I am getting this error:
Syntax error: Missing operand after '14' operator.
Can anybody help me with this ?
-
Oct 21st, 2009, 07:13 AM
#2
Re: Syntax error: Missing operand after '14' operator.
Don't use string concatenation to build SQL statements. Always use parameters to insert variables into SQL statements. Follow the Database FAQ link in my signature and check out the ADO.NET resources there for explanations and examples.
-
Oct 21st, 2009, 07:21 AM
#3
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
What does concatenation mean?
I am using:
Code:
Dim dr As System.Data.DataRow() = _DsSQL.tblCleaning.Select("Starttime >= " & dtpStart.Value)
and .Net Framework data provider for SQL
-
Oct 21st, 2009, 07:24 AM
#4
Re: Syntax error: Missing operand after '14' operator.
concatenation is just adding strings together like this:
Code:
StringOne = StringTwo & StringThree
That is fine if you just want to combine two normal strings but in an SQL statement there are special characters to watch out for, so it is better to use Parameters to avoid any problems. See JMC's post: http://jmcilhinney.blogspot.com/2009...in-adonet.html
-
Oct 21st, 2009, 07:27 AM
#5
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
So the tableadapter.select statement should not be used?
-
Oct 21st, 2009, 07:29 AM
#6
Re: Syntax error: Missing operand after '14' operator.
What makes you say that? I didnt even mention that method...
its this part that is the problem: "Starttime >= " & dtpStart.Value
-
Oct 21st, 2009, 07:30 AM
#7
Re: Syntax error: Missing operand after '14' operator.
What does concatenation mean?
Look it up.
You said that you wanted to select some rows from a SQL Server Express table. That is NOT a SQL Server Express table. That is a DataTable. That is something else entirely. the fact that the data may have come from SQL Server Express in the first place is completely irrelevant. A DataTable is a DataTable regardless of where the data came from. It has specific connection to any database.
Have you read the documentation for the DataTable.Select method? It provides a link to the documentation for the DataColumn.Expression property for syntax. It shows you how to format dates in this scenario.
There's a wealth of information out there. If you don't go and look for it then you won;t find it. If you sit back and wait for others to provide you with information that you could find for yourself with a few clicks then you're really only holding yourself back.
-
Oct 21st, 2009, 07:42 AM
#8
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
There is nothing there: http://msdn.microsoft.com/en-us/libr...wx(VS.80).aspx
Is there a manual how to use the msdn website? Haven't been able to find out how it works for the past 7 weeks that I program using vb.net. It's terrible. When you use the search option you just mostly get results from social.msdn the forums.
-
Oct 21st, 2009, 07:43 AM
#9
Re: Syntax error: Missing operand after '14' operator.
-
Oct 21st, 2009, 07:45 AM
#10
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
That was for if you wanted to select data directly from a database. I want to get data from the dataset using tableadapter.select method.
I should have given more information in my first post, sorry for that.
-
Oct 21st, 2009, 07:45 AM
#11
Re: Syntax error: Missing operand after '14' operator.
No, its the same thing
-
Oct 21st, 2009, 07:48 AM
#12
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
Ok in that case I'll get some coffee and study it .
Edit:
Jmcilhinney was talking about documentation about the datatable.select method. Do you by any chance know where I can find that? Can't find it using the msdn libarary :S.
Last edited by gonzalioz; Oct 21st, 2009 at 07:51 AM.
-
Oct 21st, 2009, 07:53 AM
#13
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
I got it, tank you both. Sorry for being a bit pissed off. I guess I am a bit too tired today. I was constantly using the wrong word.... should have been datatable.select (jmcilhinney 's post) instead of what I been using tableadapter.select.
Thnx again.
-
Oct 21st, 2009, 07:55 AM
#14
Re: Syntax error: Missing operand after '14' operator.
Actually I am a bit confused now as well lol because you mentioned the tableadatper I thought you were using that but just going back to look at your code I can see you are using a datatable. So forget what I said...
As for the documentation: http://msdn.microsoft.com/en-us/libr...le.select.aspx
(I just searched google for DataTable.Select to find that)
EDIT: Ah, I see you have sorted it now anyway
-
Oct 21st, 2009, 07:56 AM
#15
Thread Starter
Hyperactive Member
Re: Syntax error: Missing operand after '14' operator.
Originally Posted by chris128
Actually I am a bit confused now as well lol because you mentioned the tableadatper I thought you were using that but just going back to look at your code I can see you are using a datatable. So forget what I said...
As for the documentation: http://msdn.microsoft.com/en-us/libr...le.select.aspx
(I just searched google for DataTable.Select to find that)
EDIT: Ah, I see you have sorted it now anyway
Yeah thnx, found that too using datatable as keyword. This must have been the most confusing topic I started so far. I'll go to bed early tonight .
Thnx again.
-
Oct 21st, 2009, 05:53 PM
#16
Re: [RESOLVED] Syntax error: Missing operand after '14' operator.
There's no need to search for anything. Just click the word in the code editor and press F1. You can do that with any type, member, keyword or identifier. That will take you straight to the appropriate documentation. The F1 key for help is standard Windows functionality.
-
Oct 22nd, 2009, 08:31 AM
#17
Re: [RESOLVED] Syntax error: Missing operand after '14' operator.
I do find that the F1 thing doesnt work all of the time (ie sometimes it just takes me to a generic page that explains how to call a method, rather than details on the specific method I had clicked on) so I tend to just use google instead... stick "MSDN" before whatever you are searching for and 9 times out of 10 it takes you straight to the MSDN doc for that class/method/whatever
-
Oct 22nd, 2009, 05:57 PM
#18
Re: [RESOLVED] Syntax error: Missing operand after '14' operator.
Originally Posted by chris128
I do find that the F1 thing doesnt work all of the time (ie sometimes it just takes me to a generic page that explains how to call a method, rather than details on the specific method I had clicked on) so I tend to just use google instead... stick "MSDN" before whatever you are searching for and 9 times out of 10 it takes you straight to the MSDN doc for that class/method/whatever
F1 is not perfect but if it doesn't take you exactly where you want to go you simply select the Index page and type in what you want yourself. I almost universally use the local documentation first, unless it's on a topic I know I won;t find on MSDN or will likely find better information on elsewhere. It's worked for me for the last 6 years.
-
Oct 22nd, 2009, 06:39 PM
#19
Re: [RESOLVED] Syntax error: Missing operand after '14' operator.
Ah well, Google works for me - each to their own
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|