Category nameļ¼šVisual Basic

MyGeneration Makes life Very easy….

March 16, 2005 / Comments Off on MyGeneration Makes life Very easy….

Well you prabably heard about MyGeneration by now if you are a regular BloggingAbout.Net reader. If you haven’t go and download it now here.

I am currently in the process of rewriting a web application and I am completely doing away with the old DAL. Instead I am using the dOOdad architecture that comes with MyGeneration.

Here are some of the advantages I found so far….

  1. About 40 % less code in the presentation layer ! ( So there is less to review as well )

  2. The code is much more readable.

  3. The Stored Procedures in the database all have a Uniform Name

  4. It’s Faster ! ( probably my old DAL wasn’t as fast as I thought)

  5. 0 lines of code in my DAL. Everything is handled in the generated Classes.

  6. I guess an overall code reduction of 70%

  7. Even the Dynamic SQL is handled in the correct SQL way (optimizing it for successive executes)

  8. Doing away with a lot of Stored procedures that would return a very specific subset

And since it’s a Web application you can do really nice stuff to the sort orders as well. Like the following….

       If Not IsPostBack Then
            Dim PubType As String = Request.QueryString.Item(“PubType”)
            If PubType = Nothing Then
‘ Load Them all
                MyPublications.Where.PublicationType.Value = PubType
                MyPublications.Query.Load() ‘ Load the specific subset
            End If
            ‘ Set Sort order

            MyPublications.Sort = MyPublications.ColumnNames.PublicationDate + ” DESC” 
            ‘ Add to cache
            Cache.Insert(“Publications”, MyPublications)
        End If

Then when you click on a header you can do stuff like….

    Private Sub dgPublications_SortCommand(ByVal source As Object, ByVal e As  System.Web.UI.WebControls.DataGridSortCommandEventArgs) Handles dgPublications.SortCommand
        ‘ Get from the cache
        MyPublications = Cache.Get(“Publications”)
        ‘ Set new sortexpression but keep results sorted on date
        MyPublications.Sort = e.SortExpression + ” , ” + MyPublications.ColumnNames.PublicationDate + ” DESC”
        ‘ Add to cache, but first delete the old one
        Cache.Insert(“Publications”, MyPublications)
    End Sub

You don’t have to requey anything just set the sortcommand on the Entity, rewind the stuff and bind it again….
And you could do the same with filters although I haven’t used that yet….

Also a deletecommand on the datagrid is easy as …..

            Dim key As Integer = CInt(dgPublications.DataKeys(e.Item.ItemIndex).ToString())
            Dim DelPublication As New Publications

Really easy ! No forgotten connetcions or stuff like that. and the code is still easy to read…….

Also note the Difference between the following….
           MyPublications.LoadByPrimaryKey(Key) ‘ Load the specific record
          MyPublications.Where.PublicationType.Value = PubType
     MyPublications.Query.Load() ‘ Load the specific subset
          MyPublications.LoadAll() ‘ Load them all !

This made me do away with a couple of stored procedures……….. Reducing the SQL Code as well…..


Awesome Dynamic SQL generation….


Played around a littlebit with the dOOdad architecture of MyGeneration. Besides a lot of nice features there is also the the dynamic query feature…. Let me show what I mean…..

‘ See if it is in cache
Mymenu = Cache.Get(“DefaultMenu”)
If Mymenu Is Nothing Then
‘get the default Menu
Dim MyMenuID As New MenuID
MyMenuID.Where.MenuDescription.Value = “DefaultMenu”
‘Now get the MenuEntries for the menu !
Mymenu = New MenuData
Mymenu.Where.MenuID.Value = MyMenuID.ID
Mymenu.Where.MenuID.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal
‘ Only those rows that we are Authenticated to see
Mymenu.Where.AuthenticationLevel.Value = Session(“AuthenticationLevel”)

   Mymenu.Where.AuthenticationLevel.Operator = MyGeneration.dOOdads.WhereParameter.Operand.LessThanOrEqual
   Mymenu.Query.AddOrderBy(Mymenu.ColumnNames.MenuOrder, ,myGeneration.dOOdads.WhereParameter.Dir.ASC)
‘Cache this menu.
Cache.Insert(“DefaultMenu”, Mymenu)
End If
‘Bind to the grid
MenuGrid.DataSource = Mymenu.DefaultView

In the blue piece of code we set some where parameters and add a sortorder. Everything resulted in the following query beeing executed :

SELECT * FROM [MenuData] WHERE [MenuID] = @MenuID1 AND [AuthenticationLevel] <= @AuthenticationLevel2 ORDER BY [MenuOrder] ASC

And this is a really nice query, nothing wrong with that !. I just was surprised how easy it was !.




Awesome Code generation !!!!

Have a look at MyGeneration. ( Click the link !!!!!!!!!!!, don’t miss out….. )

This is a freeware code generation tool that really works…..Normally I use the NorthWind database to test code generation and I test it in VB.Net and C#. Usually I have to modify stuff on some points to get the stuff working.

And now I came across this beauty !!!!.

Really try it…… !!! …………..There are several supported architectures but the best (until now) is the dOOdad architecure… (Yes click the link to see what it is………..)

I think it is really awesome….. I just pointed it to the NortWind Database and it worked at once…..
If you are interested in productivity tools have a look at it.

Oh yes and the beauty of it all…. It is all NATIVE .Net…. Not an ugly unknown DLL somewhere NO… everything is compiled. You only have to add a referrence to the dOOdad project.

Ok….. so far I told you to go and visit the website ….Here are some reasons why……..

Very easy dynamic queries………

Dim emps As New Employees
‘ LastNames that have “A” anywhere in them
emps.Where.LastName.Value = “%A%”
emps.Where.LastName.Operator = WhereParameter.Operand.Like_


Dim emps As New Employees
‘ LastNames that have “A” anywher in them
emps.Where.LastName.Value = “%A%”
emps.Where.LastName.Operator = WhereParameter.Operand.Like_
‘ Only return the EmployeeID and LastName
‘ Order by LastName
‘ (you can add as many order by columns as you like by repeatedly calling this)
emps.Query.AddOrderBy(Employees.ColumnNames.LastName, WhereParameter.Dir.ASC)
‘ Bring back only distinct rows
emps.Query.Distinct = True
‘ Bring back the top 10 rows
emps.Query.Top = 10

Easy Iteration

Dim emps As New Employees
If emps.LoadAll() Then
   Dim lastName As String
‘  Iteration walks the DataTable.DefaultView, see the FilterAndSort
‘ sample for further clarification.
      lastName = emps.LastName
   Loop Until Not emps.MoveNext
      lastName = emps.LastName
   Loop Until Not emps.MoveNext
End If

Easy Bulk Update

Dim emps As New Employees
If emps.LoadAll() Then
‘ Modify the LastName column in every row
emps.LastName = emps.LastName + “W”
Loop Until Not emps.MoveNext
‘ Rewind and mark the first row as Deleted
‘ Add a new row and fill it in
emps.FirstName = “Jimmy”
emps.LastName = “Lunch Box”
‘ Save all modifications, deletes, and new rows
End If

And there are many many more templates based on the dOOdad architecture… Even screens are generated automatically !!!!!


Is this a Good Idea or not ?

I really don’t know if it is……(and I would Really like your Feedback about it)  I have been keeping myself busy with building a SmartGrid.

The Idea is to tell a datagrid where to get it’s data in the property section of the grid. Place the form on a grid and be done with it….. No coding needed.

I don’t know if this will fit a 3-tier architecture (or any architecture at all) and that’s where you guys come in. You can give me feedback about it. Would this be a usefull control or not ?

After placing the SmartGrid on a form you will have some extra properties below is a screenshot of this

if the autoload is set to true you the grid will load itself with data. After clicking on the “DataSetmethod” you will be able to select the DLL where to get the data from…

<IMG src="/wp-content/uploads/sites/7/2014/01/missing.jpg"


Just compile and run and the grid will be filled with data.

I am really curious if this is a good idea ?

To download the project goto the  GotDotNet Workspace 

BizTalk Adapter Wizard problems….

December 23, 2004 / Comments Off on BizTalk Adapter Wizard problems….

I Have some problems with the BizTalk Adapter Wizard.

Let me explain…..I try to make a receive adapter and have found some problems with the Adapter Wizard. It has to do with the batches. On some point there is a the following lines

While (NrOfMessages < SPXAdapterProperties.BatchSize And Not Me._manageEndpoints.TerminateCalled)
< some code here>
End While

Ok let me explain :

SPXAdapterProperties.BatchSize is 20
NrOfMessages = 0 ( is only increased if we really receive a message but in my case we received nothing)

Then if I stop the receive location I would expect something happening to “Me._manageEndpoints.TerminateCalled“ like it was set to True but this is not the case.

I Start my receive location, but I Don’t receive any messages. I Stop the Receive location and the Adapter is stuck into this loop.

The only way of getting out of this loop is to stop BTS. But it will take ages then. Is there anybody out there that has similar problems with the Adapter Wizard




Ok Very BASIC .NET Question

Ok to all the WASABI guru’s out there that complain there is too much Biztalk on Wasabi.

Is there a way I can place a text over an image in ASP.NET ?

I tried several things. But let me explain a little…….

I have a picture say 3 pixels wide and 200 pixels long, quite like a cigarette. The picture itself is a gradient going from white to blue or whatever colors you fancy. The problem is that only an image control can stretch the image horizontal and repeat vertical.

I want to place text over this image and keep the gradient intact ( where the gradient is stretched over the full 1024 pixels).

I can do this by drawing a table of one cell and give it a background picture. Then put a label in this table and voila. Problem is the image doesn’t stretch.

I have seen zillions of solutions that generate an image with the text in it, but after a screen resize it looks really afwull. How hard can it be to put some text on an image ?

I also tried stuff with

and that worked but then I had to absolutely position the control making it useless for my project.
Tried the CSS but couldnt find what Í was looking for.

Is there any ASP.NET guru/Stylesheet Guru/GuruGuru that can help ?


  • Recent Posts
  • Recent Comments
  • Archives
  • Categories
  • Meta