1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Stackoverflow]

Discussão em 'StackOverflow' iniciado por fdantas, Fevereiro 3, 2021.

  1. fdantas

    fdantas Administrator Moderador

    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

    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

    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 :

    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)

    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...

Compartilhe esta Página