Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. A C# / SQL Query Problem

A C# / SQL Query Problem

Scheduled Pinned Locked Moved C#
databasehelpcsharpsql-serversysadmin
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cemlouis
    wrote on last edited by
    #1

    Hi, I want to send to SQL server a query I want to get randomly generated 100 rows where they are no generated before. I made my query like below: mySqlCommand.CommandText = "SELECT name,rand(name) FROM people LIMIT 100 WHERE generated_before IS NULL"; Gives system error??? Thank you, Cem Louis

    C C C 3 Replies Last reply
    0
    • C cemlouis

      Hi, I want to send to SQL server a query I want to get randomly generated 100 rows where they are no generated before. I made my query like below: mySqlCommand.CommandText = "SELECT name,rand(name) FROM people LIMIT 100 WHERE generated_before IS NULL"; Gives system error??? Thank you, Cem Louis

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You want to generate 100 rows, or get back 100 rows at random ? Christian I have drunk the cool-aid and found it wan and bitter. - Chris Maunder

      1 Reply Last reply
      0
      • C cemlouis

        Hi, I want to send to SQL server a query I want to get randomly generated 100 rows where they are no generated before. I made my query like below: mySqlCommand.CommandText = "SELECT name,rand(name) FROM people LIMIT 100 WHERE generated_before IS NULL"; Gives system error??? Thank you, Cem Louis

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        I'm not sure when you get the LIMIT keyword from, it doesn't appear to be a valid T-SQL keyword. Try SELECT TOP 100 .... Also, the RAND() function only accepts interger types. I am assuming that name is a string of some kind. I am not sure what you are trying to do with RAND() If you can explain more about what you are trying to do I might be able to help more.


        Do you want to know more? Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

        1 Reply Last reply
        0
        • C cemlouis

          Hi, I want to send to SQL server a query I want to get randomly generated 100 rows where they are no generated before. I made my query like below: mySqlCommand.CommandText = "SELECT name,rand(name) FROM people LIMIT 100 WHERE generated_before IS NULL"; Gives system error??? Thank you, Cem Louis

          C Offline
          C Offline
          cemlouis
          wrote on last edited by
          #4

          Anyway I did it like below: "SELECT TOP 100 name FROM people ORDER BY NEWID()" Cem

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups