1

I am trying to execute a simple SQL query from c# using ADO.net adapter.

Query access data from two tables using join.

Below is my code

newRequest=getrequest.selectQuery("select A.associateID, A.name, A.role, A.Salt FROM associate A INNER JOIN UserStatus UA ON UA.statusID=A.status" +
             "WHERE A.coordinatorID='"+cID+"' AND UA.statusName='WAITING FOR APPROVAL'");

con.Open();               
SqlDataAdapter sd = new SqlDataAdapter(query, con);
sd.Fill(ds);

I get error on execution:

Incorrect syntax near 'A'

2
  • 1
    I think there's a space missing in front of WHERE clause Commented Nov 4, 2016 at 8:45
  • Thanks. that's a silly mistake :D Commented Nov 4, 2016 at 8:47

1 Answer 1

2

Try below code:

newRequest=getrequest.selectQuery("select A.associateID, A.name, A.role, A.Salt FROM associate A " +
"INNER JOIN UserStatus UA ON UA.statusID=A.status "
"WHERE A.coordinatorID='" + cID + "' "
"AND UA.statusName='WAITING FOR APPROVAL'");

con.Open();               
SqlDataAdapter sd = new SqlDataAdapter(query, con);
sd.Fill(ds);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.