StrataFrame Forum

Standard ADO.Net components works with ES?

http://forum.strataframe.net/Topic26695.aspx

By Luiz Lima - 3/30/2010

Hi,



I´d like to know if the code below works when I using a ES connection.



Tks



con = New SqlConnection(sConnectionString)

con.Open()

ds = New DataSet()

sSql = "select cli_campo01, cli_campo02, cli_classe, cli_nome from tb_cliente "

dap = New SqlDataAdapter(sSql, con)

Dim dt = New DataTable()

dap.Fill(dt)

If dt.Rows.Count > 0 Then

dim campo1 as string = dt.Rows(0).Item("server_cliente")

dim campo2 as string = dt.Rows(0).Item("db_cliente")

classe_cliente = dt.Rows(0).Item("cli_classe")

nome_cliente = dt.Rows(0).Item("cli_nome")

end if

By Greg McGuffey - 3/30/2010

As far as I know, no it won't. It only deals with BOs. I know when I started using ES, I had to redo a couple of things that were using ADO.NET directly.



Note that you can use a generic BO, or even the BusinessLayer directly to get a Datatable filled:



'-- Use a generic BusinessLayer to fill a datatable and get some arbitrary data.

Dim campo1 As String = String.Empty

Dim campo2 As String = String.Empty

Using bo As New BusinessLayer()

  '-- Set data source key, so it can find data.

  bo.DataSourceKey = ""



  '-- Fill BO's data table using a SQL command...could just use the String overload

  '   but if you are passing params, then this is the way to go.

  Using cmd As New SqlCommand()

    cmd.CommandText = "select cli_campo01, cli_campo02, cli_classe, cli_nome from tb_cliente "

    bo.FillDataTable(cmd)

  End Using



  '-- If there are any items, load data. It'll be on the first row by default.

  '   If you need to move to another row, BO has methods to get this done.

  If bo.Count > 0 Then

    campo1 = Ctype(bo.CurrentRow("server_cliente"), String)

    campo2 = Ctype(bo.CurrentRow("db_cliente"), String)

    classe_cliente = Ctype(bo.CurrentRow("cli_classe"), String)

    nome_cliente = Ctype(bo.CurrentRow("cli_nome"), String)

  End If

End Using
By Luiz Lima - 3/31/2010

Greg,

Fantastic!
I didn´t know the use of generic BO, this open a large of possibilities to me.
Can I use this generic BO with Business Binding Source?

Tks!

By Greg McGuffey - 3/31/2010

Not sure about that, but it might be possible. I'm not sure how the BBS does its "magic", if it uses the field properties or just whatever datatable is loaded into the BO. If it's just using the data table, then I'm guessing this would work.
By Luiz Lima - 4/8/2010

Greg,

Sorry by late.
I tested the code but I´ve got an error about override TableName, how can I do that?

See the screen shot


tks

Luiz

By Greg McGuffey - 4/8/2010

Oops. I haven't done this in a while. You have actually build a BO using the BO mapper so all the required override properties are handled. I guess a better way of expressing this is to say that you can use any BO to generically retrieve data. I'm working on an example which should be done tomorrow.
By Greg McGuffey - 4/9/2010

I just posted a sample demonstrating how you might do this.



http://forum.strataframe.net/FindPost26800.aspx
By Trent L. Taylor - 4/12/2010

Great job, Greg. Thanks for the samples! Smile