Error in query

Status
Not open for further replies.

mrprogman

New Member
Hi.. I got a database in progress 10.1, i want to pull info from one field call 'sup-id', from visual 2008 in asp.net. but i got this error

ERROR [HY000] [DataDirect][ODBC OPENEDGE driver][OPENEDGE]Syntax error in SQL statement at or about "[ord_0.sup-id] FROM PUB.ord ord_0 WHERE " (10713)


this is my query:

Dim MyConnection As System.Data.Odbc.OdbcConnection = New System.Data.Odbc.OdbcConnection("Driver={Progress Openedge 10.1A Driver};DSN=PROGRESS;DB=pace;UID=sysprogress;PWD=password;HOST=192.168.10.248;PORT=2580;")
Dim MyCommand As System.Data.Odbc.OdbcDataAdapter = New System.Data.Odbc.OdbcDataAdapter("SELECT ord_0.onum, ord_0.cdate, ord_0.completed, ord_0.posted, ord_0.sid, [ord_0.sup-id] FROM PUB.ord ord_0 WHERE (ord_0.cdate>={d '2011-06-01'}) AND (ord_0.completed Is Null) AND (ord_0.sid=1)", MyConnection)
Dim DS As DataSet = New DataSet
MyCommand.Fill(DS, "ord")
aspxGridView1.DataSource = DS.Tables("ord").DefaultView
aspxGridView1.DataBind()


can i can help me please...?
 
tables, fields with illegal characters (in that case '-') should be quoted...

Code:
SELECT ord_0.onum, ord_0.cdate, ord_0.completed, ord_0.posted, ord_0.sid, ord_0."sup-id" FROM PUB.ord ord_0 WHERE (ord_0.cdate>={d '2011-06-01'}) AND (ord_0.completed Is Null) AND (ord_0.sid=1)
 
The only thing you can do is to surround the fields which contain illegal characters with double quotes. Then the query should work.

Heavy Regards, RealHeavyDude.
 
What's your problem. Double quoting table and column names containing illegal characters like - *is* the solution unless you want to construct views that don't have the dash or change the schema. It may not be the only thing wrong and you might have to give us more information for that, but it *is* the answer to that particular issue.
 
This is the solution..................................
dim supid as string
supid = "ord_0." & """sup-id"""
Dim MyCommand As System.Data.Odbc.OdbcDataAdapter = New System.Data.Odbc.OdbcDataAdapter("SELECT ord_0.onum," & supid & ", ord_0.sid, ord_0.cdate, ord_0.posted, ord_0.expected, ord_0.completed FROM PUB.ord ord_0 WHERE (ord_0.sid=0) AND (ord_0.cdate>{d '2011-01-01'})", MyConnection)

is so difficult to do this.?
 
What's your question? You could have put the quotes around sup-id in the literal string without creating a separate variable. I.e.,
... ord_0."sup-id" ...
If the whole thing is quoted then you need to use the number of quotes specified by the language for quote within quote or change the outside quotes to single quotes if that is allowed by the context.
 
Then there was an error in your test since composing the string as a separate variable is going to make no difference in the result.
 
well, looks like you really have a few things to learn and that's not only language syntax :)

anyway... glad to see you found the answer yourself, after all wasn't that hard isn't it?
 
Status
Not open for further replies.
Back
Top