problem with database access [modified]
-
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
-
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
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