0

I'm using Oracle developer tools and my generated select command is:

SelectCommand = "SELECT "FIRSTNAME" FROM "USERS" WHERE ("USERNAME" = ?)">`

Then I removed all " and replaced them with a single quote: '.

Then I get that error (mentioned in the title).

Any suggestions how I can make it work?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
kisbovan93
  • 45
  • 10

1 Answers1

0

You should be using like this

select firstname from users where username='%?'

Just replace the value in the where condition with your live values. Note down the syntax of SQL

Saravanan
  • 7,637
  • 5
  • 41
  • 72
  • Fine, basic SQL syntax is a bit common . if this worked, you can mark this as answer – Saravanan Mar 28 '15 at 12:54
  • Im sorry, but it doesnt work after all. However, the error message doesnt show up anymore, the return value is empty. So there must be something with the query, because the same query works and returns a value when Im doing it in SQLTools. – kisbovan93 Mar 29 '15 at 10:40
  • it means that your where clause has something wrong. post the sql query that you are generating now and we can figure out whats the problem – Saravanan Mar 29 '15 at 10:44
  • So Im getting my parameter from a textbox, but I tried with a default value as a parameter, the result says it is still empty (I used the count method on the sqldatasource to make sure it has a result at all or not) – kisbovan93 Mar 29 '15 at 10:49
  • you should be using like this `SELECT * FROM Employees WHERE UserName = ?` as given here: https://msdn.microsoft.com/en-us/library/z72eefad%28v=vs.140%29.aspx or take a look at the sample here, though for a different one, but will be useful for you. http://forums.asp.net/t/1158209.aspx?oracle+SqlDataSource+parameter+mismatch – Saravanan Mar 29 '15 at 11:00
  • yep, I tried with SELECT * FROM Employees WHERE UserName = ?, but it shows an invalid character exception again. And when I write '%?' instead of ?, the error disappears, but the return value is again empty. – kisbovan93 Mar 29 '15 at 11:02
  • After all, the latest link you gave me had an awesome hint and it worked, thanks so much! – kisbovan93 Mar 29 '15 at 11:08