[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 :(?
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.
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
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
Re: Syntax error: Missing operand after '14' operator.
So the tableadapter.select statement should not be used?
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
Re: Syntax error: Missing operand after '14' operator.
Quote:
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.
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.
Re: Syntax error: Missing operand after '14' operator.
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.
Re: Syntax error: Missing operand after '14' operator.
No, its the same thing :)
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.
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.
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 :)
Re: Syntax error: Missing operand after '14' operator.
Quote:
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.
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.
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 :)
Re: [RESOLVED] Syntax error: Missing operand after '14' operator.
Quote:
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.
Re: [RESOLVED] Syntax error: Missing operand after '14' operator.
Ah well, Google works for me - each to their own :)