[Stackoverflow] [Progress OpenEdge ABL] OpenEdge/Progress DB Parameters in Query

Status
Not open for further replies.
L

Litation

Guest
I’m trying to write an small c# app to connect to a ProgressDB but I’m failing at a pretty early stage.... writing a query that takes a parameter. For context I had not even head of progress until last week (I am a mainstream MSSQL monkey)

If I were writing my query in TSQL it would just be

Code:
DECLARE @Id nvarchar(15) = 'X1234'
SELECT * from People WHERE Id = @Id

Now I can write a hardcoded select statement for progress using ODBC query tool

Code:
Select * from People where "Id" = 'X1234'

But I don’t know how to parameterise it, I’ve had a look at the Progress/OpenEdge KB but its doesn't seem as simple as X = "Y" call X.

I could do something horribly messy (With the added benefit of make my senior Devs cry) in my C# code and do the following :

Code:
string sqlstr = "Select * from People where " + "\"" + "Id" + "\" ' = " + id + "'";

but I really want to be doing something like this. Obviously this is using SqlConnection rather than OdbcConnection but that’s a problem for tomorrow me to fix (Tomorrow me doesn’t really like yesterday me much)

Code:
public async Task<IEnumerable<Data>>GetMeMyData(string id)
        {
            using (var connection = new SqlConnection(_configuration.GetConnectionString("MyDB")))
            {
                var sqlQuery = "Select * from People where \"ID\" = '@Id'";

                return await connection.QueryAsync<Data>(sqlQuery, new { Id = id });
            }
        }

Any advice or links to a good eli5/babies first progress query would really be appreciated Thanks (and hopefully that all makes sense).

Continue reading...
 
Status
Not open for further replies.
Top