Populating a WinDev Table from a SQL Server View

It’s not possible to add a SQL Server View in WinDev 11 to the Analysis file, so here is a simple way to do this using a few lines of WLanguage code.

First we create a Data Source which we can then map to our table component.

image

Now lets get the data from the SQL Server View.

image

Finally we read through the results and populate the table. Note that I have already added the table to the window and added the columns.

image

You use the Data Source to read through the records and fields. There is no intellisense in the Data Source so you will need to know the field names. For Example, Cost_Centre_Code in the code above is a field return from the view. The TAB is used as a break between each column in the Table Component.

Note that you need to add data using TableAdd in the same order as you have defined the columns in your component.

image

4 thoughts on “Populating a WinDev Table from a SQL Server View

  1. Hi Jonathan,

    Well done for taking the time to publish some Windev Code samples. I dont know for sure but this could be even simpler by using SQLExec to execute your query and SQLTable to whack the results into the table in one line.
    Cheers

    BOb

  2. Addendum: You will need to define the connection and use SQLConnect first. ALso remember to use SQLDisconnect as some DBMS do not kill off idle connections. (MySQL gets a little unhappy…. :))

    B

  3. Hi Osvaldo

    I have found WinDev to be very productive compared to .NET. The WLanguage functionality as fantastic and I have found many situations where just a few lines of code in Wlanguage would have taken me hundreds of lines of code in .NET.

    I am still getting my head around some areas of WinDev, including being able to define different elements of a project to compile as exe, components or web services etc.

    We also have WebDev though I have yet to work through some projects with that.

    Best regards

    Jonathan

Leave a Reply

Your email address will not be published. Required fields are marked *