Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Syntax Error (Missing Operator) In Query Expression

syntax syntax error

  • Please log in to reply
2 replies to this topic

#1 percis

percis

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 72 posts
  • Programming Language:C
  • Learning:C#, (Visual) Basic

Posted 10 July 2012 - 07:26 PM

private void button1_Click(object sender, EventArgs e)
	  {
		 OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Student\Documents\Database3.accdb");
		 OleDbCommand command = new OleDbCommand ("SELECT empName"+"FROM emp"+"ORDER BY empName",conn);
		 try
		 {
		    conn.Open();
		    OleDbDataReader reader = command.ExecuteReader();
		    while (reader.Read())
		    {
			   MessageBox.Show(reader["empName"].ToString());
		    }
		    reader.Close();
		 }
		 catch (OleDbException ex)
		 {
		    MessageBox.Show(ex.Message);
		 }
		 finally
		 {
		    conn.Close();
		 }
how to correct the syntax error (missing operator ) in query expression 'empName FROM emp ORDER BY empName' ?
  • 0

#2 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 11 July 2012 - 01:48 AM

there is no spaces in your query, as of now, it says "SELECT empNameFROM empORDER BY empName" if you evaluate the pluses first...
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#3 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts
  • Programming Language:C, C++, C#, JavaScript, PL/SQL, Delphi/Object Pascal, Visual Basic .NET, Pascal, Transact-SQL, Bash

Posted 11 July 2012 - 06:19 AM

That's the answer, but the solution brings another question: Why are you concatenating the string at all?
  • 0
My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth





Also tagged with one or more of these keywords: syntax, syntax error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download