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. Database & SysAdmin
  3. Database
  4. problem with database access [modified]

problem with database access [modified]

Scheduled Pinned Locked Moved Database
helpdatabasequestion
2 Posts 2 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.
  • S Offline
    S Offline
    sreecahitu
    wrote on last edited by
    #1

    Am retrieving data from my databese engine to read the data, but encountering an error at dr.Read(), con.close() string connection=@" "; SqlConnection con = new SqlConnection(connection); SqlCommand cmd = new SqlCommand("select * from employee",con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); con.Close(); "Invalid token '(' in class, struct, or interface member declaration", what could be the reason for this? -- modified at 18:57 Friday 9th February, 2007

    C 1 Reply Last reply
    0
    • S sreecahitu

      Am retrieving data from my databese engine to read the data, but encountering an error at dr.Read(), con.close() string connection=@" "; SqlConnection con = new SqlConnection(connection); SqlCommand cmd = new SqlCommand("select * from employee",con); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); con.Close(); "Invalid token '(' in class, struct, or interface member declaration", what could be the reason for this? -- modified at 18:57 Friday 9th February, 2007

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

      sreecahitu wrote:

      Invalid token '(' in class, struct, or interface member declaration

      I don't know why that error occurs. There is not enough information given. However, I can point out other problems with the code. 1. The connection string is empty (although I'm guessing you removed it for security) 2. You never open the connection. 3. You read from the database but you never check if anything exists, and if it does exist you never actually get the data.


      Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

      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