Results 1 to 19 of 19

Thread: [RESOLVED] Syntax error: Missing operand after '14' operator.

  1. #1

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    Resolved [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 ?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  3. #3

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    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

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  5. #5

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    Re: Syntax error: Missing operand after '14' operator.

    So the tableadapter.select statement should not be used?

  6. #6
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  8. #8

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    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.

  9. #9
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Syntax error: Missing operand after '14' operator.

    Have you looked at the link I gave you?
    http://jmcilhinney.blogspot.com/2009...in-adonet.html
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  10. #10

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    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.

  11. #11
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Syntax error: Missing operand after '14' operator.

    No, its the same thing
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  12. #12

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    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.

  13. #13

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    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.

  14. #14
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  15. #15

    Thread Starter
    Hyperactive Member gonzalioz's Avatar
    Join Date
    Sep 2009
    Location
    <body></body>
    Posts
    508

    Re: Syntax error: Missing operand after '14' operator.

    Quote Originally Posted by chris128 View Post
    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.

  16. #16
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    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.

  17. #17
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  18. #18
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,299

    Re: [RESOLVED] Syntax error: Missing operand after '14' operator.

    Quote Originally Posted by chris128 View Post
    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.

  19. #19
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] Syntax error: Missing operand after '14' operator.

    Ah well, Google works for me - each to their own
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width