Category Archives: dotNET

VTdotNET Holiday Party – even with a live jazz band!

In the past, the December “meeting” for Vermont.NET has been a pot-luck gathering at either someone’s office or house. This year, with other (less stingy? ;-)) folks than myself in charge, we are having a real party! It’s going to be at Parima Thai in Burlington which has a really cool private party room designed in the feel of Frank Llloyd Wright. And member, Paul Swider, has somehow gotten his friends from Pine Street Jazz to play at the party! It’s like a real office party. Appetizers will be provided and there will be a cash bar. Parima is even offering a discount to any of our members who want to have dinner at their Thai Buffet before or after the party. We will still do our pot-luck in the form of desserts as well as collect food for Vermont Foodbank.

Thanks to Parima and Pine Street Jazz for making this affordable and to local c-tech, Knowledgewave, for their sponsorship!

Don’t Forget: www.acehaid.org

How many programmers does it take to …(TFS scales way up)

Etienne Tremblay is a real VSTS wonk. (Etienne is French Canadian, so I should be sure to remind him that “wonk” is a good word..). He works at EDS, which is one b-i-g company, and is excited about the fact that Microsoft has just changed it’s Team Foundation Server recommendations from “Teams of up to 500 users” to “Teams of up to 2000” users. That’s a lot of programmers mucking with your code. But one has to understand that I am an independent so it’s basically unfathomable to me….

Don’t Forget: www.acehaid.org

My first VS2005 RTM lockup

whaa, me too. I was changing the fore color of a label on a winform with very few controls on it. The label’s color changed. Then cross hairs cursor appeared and started flashing. Then I got the hourglass. Then it all stopped and the ol “(Not Responding)” appeared on the windows title.

This is on a machine that was totally repaved prior to installing RTM bits.

ah well…

I was, however, able to close and save the app.

Don’t Forget: www.acehaid.org

VTdotNETters – you’ve got the books, now here’s some help reviewing them

Over the past nearly 4 years of Vermont.NET, I have given away hundreds of books donated by publishers. Early on, I enabled the VTdotNET website so that the recipients of those books could post reviews of them. Here is our book review page and our software review page. It’s the least we can do in return for receiving the books.

After about a year, I gave up on begging, harrassing and otherwise attempting to get people to review books and even software licenses – sometimes valued in the thousands.

If you have a book that you got from VTdotNET, we would still appreciate your review. It doesn’t have to be your life’s work. Here are some great tips from O’Reilly about writing book reviews.

Don’t Forget: www.acehaid.org

Dynamically embed image files into Crystal Reports in VS2003 (and probably VS2005, too)

In VB6 with Crystal Reports 8, embedding an image dynamically into a Crystal Reports file was fairly simple. You could merely add a new object to the report on the fly, passing in the path of the image file then drop it into the appropriate section and x/y position on the report.

Dim oleobj As OLEObject
oRpt.Sections(8).AddPictureObject imgfileName, 1920, 1560

In VS.NET 2003 (I haven’t looked at how to do this in 2005 yet), it is hardly as easy as this and I needed to do it to solve a serious file bloat problem. I had a 13kb image that I needed to embed as a watermark into the background of the file. You do this by creating a page header section that is the height of the paper and in the formatting options for the section, check “Underlay Following Sections”. That way, the section will be a watermark under all of the rest of the sections of the report. However, because of the way Crystal does this underlay, my dlls that contain a report with a watermark were over 2MB when compiled. Without the image, they went back down to 200kb – 350kb depending on other variables.

Embedding the watermark image dynamically was going to help me get rid of this file bloat problem, but it was not as simple as the previous crystal API.

I had some help from tech support and modified the code to suit my needs and will share it here.

The trick is to stream the file into a datatable and then add the datatable as one of the datasource objects of the report. Then the field which represents the image, can be dragged and dropped onto the report surface.

What I did was create a class for extending Crystal call CrystalAddOns. In it I have a shared function that takes in the path of the image file and returns a datatable creating the binary for the image.

Here is the class.

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data
Imports System.IO
Public Class CrystalAddOns

‘========================

Public Shared Function ImageTable(ByVal ImageFile As String) As DataTable
‘ Create a dataTable
  Dim data As New DataTable
‘ Declare a row object.
 
Dim row As DataRow
 
data.TableName = “Images”
‘ Add a Byte Array field to the dataset.
 
data.Columns.Add(“img”, System.Type.GetType(“System.Byte[]”))
‘ Repeat for each image.if you have more than one…
‘==================
‘ Read in the image file.(in VS2005 you can use ReadAllBytes and skip the streaming)
  Dim fs As New FileStream(ImageFile, FileMode.Open)
‘ Create a new binary reader object.
  Dim br As New BinaryReader(fs)
‘ Create a new row object.
  row = data.NewRow()
‘ Stream the image into the row.
  row(0) = br.ReadBytes(br.BaseStream.Length)
‘ Add the row to the dataset.
  data.Rows.Add(row)
 
br =
Nothing
  fs.Close
  fs = Nothing
‘==================
‘ Run through this line of code the the first time you create the dataset
‘ To create the schema file. The schema file will be the datasource for the
‘ subreport that holds the image. Add this to the project and then add it to
‘ the report in design time. Then you can drag & drop the img field onto the
‘ report.

 ‘Dim ds As New DataSet
 ‘ds.Tables.Add(data)
 
‘ds.WriteXmlSchema(System.IO.Directory.GetCurrentDirectory() & “\Image.xsd”)

Return data

‘don’t forget your exceptions!!

End Function
End
Class

Now that you have this class, you can use it easily when instantiating your reports:

rpt.Database.Tables(1).SetDataSource(CrystalAddOns.ImageTable(myfilePath)

This assumes that the schema file was the 2nd datasource in your report.

My class also has additional goo to handle specific watermarks, such as a “draft” watermark. This way my call would ask for CrystalAddOns.DraftImageTable() and the CrystalAddOns class already has the path of the file.

Note that the full blown version of Crystal Reports that can be upgraded to from the one that comes with VS2003 (and the next version that you can upgrade to from VS2005) have a Dynamic Image Location feature (which I have never tried) that supposedly makes this much simpler. My guess is that the Dynamic Image Location does the same thing as my class.

Don’t Forget: www.acehaid.org

What – still no line in WinForms designer?

I think my head has been under the rock as far as vs2005 WinForms UI design stuff is concerened. I was fiddling wtih Winforms the other day and wanted to put a line on the form and realized I still can’t do it the old VB6 way. I just dropped a panel on instead and put the “below the line” stuff inside the panel. I want the line there at design time, so the GDI+ way wasn’t my cup of tea.

Don’t Forget: www.acehaid.org

INETA Eval forms for last night’s VTdotNET meeting

Yeah – so I printed the eval forms just before I left my house and left them sitting in the printer! Attendees of last night’s meeting can get the form from the Vermont.NET home page (top of page). Please email them back to me after you fill them out. Filling out the forms is what assures that I get reimbursed for last night’s pizza and soda!!

Don’t Forget: www.acehaid.org