ADAL v0.2

ADAL v0.2

ADAL (Auto Data Access Layer) is a utility to generate the stored procedures and .NET classes needed to get up and running with a basic Data Access Layer.

License

Currently ADAL may be used for free by:

  • Students
  • Government Agencies
  • Educational Institutions

ADAL may not be used:

  • For Commercial purposes
  • By BFFs

v0.2 Means Not Ready for Production

The code that ADAL generates has been tested by me for a total of about 10 minutes.  As such I would not recommend running the tool against a production database.

ADAL does not encrypt its communication with the server, so unless you know the connection between you and the database server is reasonably secure, I wouldn’t use it for databases or data that you are really attached to.  You never know who’s listening to your wire looking for a database username and password to go flying by.

ADAL also has trouble with some datatypes right now, it can generate the Stored Procedures all right, but translating some SQL server datatypes to .NET data types gives it a headache.

Is it Really That Dangerous?

No, but i’m covering my ass.  ADAL itself only issues SELECT statements against the database, you can actually run ADAL with a very low-priviliage account.  It seems that as long as the account is a data-reader, it can get the information it needs.

Of course, ADAL does generate the CREATE statements to DELETE information from your tables.  So if you were careless, you could run one of these stored procedures and delete a row of data.  That’s about the worst that can happen.

How do I use it?

  • Download the ADAL .zip file below, and unzip the .exe inside.
  • Run the .exe.
  • Fill in the server, username, and password.
  • Click Connect
  • Select the database you want to generate a DAL for.
  • Check the tables you want to generate a DAL for
  • Click “Make A DAL!”.
  • Copy the SQL from the “SQL Output” tab into query Analyzer and run it.  Make sure to select the correct database first!
  • Copy the VB code from the “VB Output” tab into a new vb class file in your project.
  • Compile.
  • Have fun.  Enjoy not writing that crap by hand.

How Do I Download?

ADAL v.01

ADAL 0.2

Changes

ADAL 0.2

  • Added color highlighting to VB tab.  Only bug is that you have to click in the VB textbox and hit a key to trigger the color highlighting.
  • The account you use to connect with used to require that it have “master” as the default database.  This has been fixed.
  • There is a bug that was introduced as well, there is tome text (“test”)included at the end of each of the VB and SQL code windows.  You’ll have to delete this text before or after you use it.

Creating Custom Collections and Binding Them

I thought this was too cool so I decided to post an example on it. 

First Create A Class
We need to create a class the items of which we will add to our custom collection.  This one’s pretty simple, it’s a car:

‘  Quick class to give us some properties

Public Class CarItem

   Public _Make As String

   Public _Model As String

 

   ‘you have to implement the properties to be able to bind it later on

   ‘ (i.e. declaring the variables as Public won’t work)

   Public Property Make() As String

      Get

         Return _Make

      End Get

      Set(ByVal Value As String)

         _Make = Value

      End Set

   End Property

 

   Public Property Model() As String

      Get

         Return _Model

      End Get

      Set(ByVal Value As String)

         _Model = Value

      End Set

   End Property

End Class

 

Create The Custom Collection
The important parts to note are the first line where we inherit from System.Collections.CollectionBase.  This provides all the basic functionality of the collection to us.

The next thing we do is to re-implement the Add and Item properties.  This is what makes it so cool.  Later on when you access these properties the intellisense knows that your adding a “CarItem” object and you have all the properties of the “CarItem” available.

The Microsoft article made the Item property ReadOnly.  I’m not sure why, I decided to implement the Item property just like the Base object’s Item Property (allowing Get and Set).

 

‘This is the custom collection that we can populate and do things like bind to .NET controls

Public Class Cars

   Inherits System.Collections.CollectionBase

 

 

   ‘Re-implement the Add method, but type it to our object

   Public Sub Add(ByVal Car As CarItem)

      list.Add(Car)

   End Sub

 

   ‘Reimplement the Item property but type it

   Public Property Item(ByVal index As Integer) As CarItem

      Get

         Return CType(list.Item(index), CarItem)

      End Get

      Set(ByVal Value As CarItem)

         list.Item(index) = Value

      End Set

   End Property

End Class

 

Using The New Collection
Now that we’ve created our new collection we can use it.  The code below shows an example of how you might bind the collection to a datagrid.  Obviously you’d probably be adding the data from a database and not manually, but this is good enough for example.  The last line also shows how you can use the item property to inspect the items within the collection.

Dim MyCarCollection As New Cars

 

‘This would be better done through a database  🙂

Dim Car1 As New CarItem

With Car1

   ._Make = “Ford”

   ._Model = “Ranger”

End With

MyCarCollection.Add(Car1)

 

Dim Car2 As New CarItem

With Car2

   ._Make = “Jeep”

   ._Model = “Wrangler”

End With

MyCarCollection.Add(Car2)

 

‘Assign our custom car collection to the cars datagrid and bind it

dgCars.DataSource = MyCarCollection

dgCars.DataBind()

 

Response.Write(MyCarCollection.Item(0).Make)

Here’s an Example of The DataGrid After Being Bound

Datagrid after it's bound to a custom collection

Pretty cool eh?

Here’s the original Microsoft Article which I basically re-implemented here 😛

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vaconCreatingYourOwnCollectionClass.asp

Upgrade to WordPress 2.0

Hey there everyone. Just thought I’d tell everyone that I’ve upgraded http://blog.killfly.com to WordPress 2.0. On yourside I suppose it doesn’t look a whole lot different, but there’s all kinds of new things for me to play with….that’s the real reason I had to write this post…

For those technical people out there, here’s what I did:

Backup Current Site

  • Exported database from MyPhpAdmin as SQL file in case I needed to restore.
  • Downloaded all the files from the blog.killfly.com subdomain to my local hard drive.

Get New Files And Prepare Upload

  • Downloaded and extracted the new WordPress2 ZIP file to my desktop.
  • Copied the config.php and php.ini from my local backup to my downloaded copy (so I can upload one big folder).

Do Actual Upload and Update

  • Deleted all the wordpress files from the blog.killfly.com server (made sure to leave my stats folders).
  • Upload new files.
  • Ran the /wp-admin/upgrade.php file as per the instructions.
  • Opened http://blog.killfly.com/ in my browser.

I realzed my custom banner was missing (my fault)…

Fix Missing Banner

  • Uploladed my personalHeader.jpg file from my local backup at wp-content\themes\default\images
  • Uncommented the line in header.php using theme editor to re-display the custom header.

Done!

Granted, my blog is fairly small, and I didn’t have any uploaded images. But I was very happy at how easy the upgrade was.

-Andrew

Largest Garlic Clove


largest_garlic_clove

Originally uploaded by firstdivision.

The largest clove of garlic I have ever cut into. Keep in mind, this is just one clove of an entire head!

This was actually a clove of garlic tha was inside a gift basket that we recieved. Since we were cooking up some chicken that was also in the gift basket, I decided to take on the garlic.

I minced about 3/4 of this clove and quickly fried it in butter,making sure not to burn or even brown it. This was added to a pan of fettucini with fresh-cut tomatoes and the garlic. This pasta/garlic mixture served as a bed for the chicken.

Yummy! Almost (but not quite) as good as Chicken Cordon Blue from Mama T’s.

File System Permissions with ASP.NET

When managing permissions for an ASP.NET application, make sure to set the permissions for the user that the application will be running under. This account is different depending on what version of IIS is running (which you can likely extend to the operating system in use).

To find the user that the application runs under, insert the following code into a page of your application:

Response.Write(Environment.UserName)

The user that Windows XP uses (in my tests) is: ASPNET
The user that Windows Server 2003 uses (also in my tests) is: NETWORK SERVICE

Another factor to consider is that the above accounts were found with the application running with “IMPERSONATE IDENTITY” = False. If it were set to true, the account would either be IUSER_MACHINENAME or the domain user if IIS has authenticated them.

Keep these issues in mind if you need to allow the end users elevated permissions (such as uploading files). You will have to give permissions to different accounts depending on what version of IIS you are using.

VSS Reporter and XSLT

Introduction
A while ago we started using Microsoft’s Visual SourceSafe at work with Visual Studio .NET 2003. One of the first things we realized when we began working with it was that the reporting capabilities were lacking to say the least. Another problem we faced was the ability to tie together changes in SourceSafe with issues in our issue tracker. By using the free tool VssReporter to find the files that changed since a label or date, we were able to accomplish both of these goals.

The only drawback about VSS Reporter is that the generated files aren’t very pretty. Fortunatly one of the output options is XML which we can make to look pretty using XSLT and CSS. And then, as long as we’re in there, let’s add some functionality to integrate a home-grown issue tracker with changes made in SourceSafe. Then we can answer the question, “What bug or feature required that this file be changed?”

XSLT
The XSLT file essentially builds an HTML page out of a supplied XML file. It was a little tedious to get working a first, but after a little bit of trial and error I was able to get the layout I wanted.

Another thing that the XSL does it to look for an occurence of “ID=” in the comment field. When files are checked into SourceSafe, we have to make sure that we use a comment that includes this string. Without it there will be no way to correspond changes made to files with the issues submitted in the issue tracker. This part is optioal to you, in fact if you don’t have “ID=” in your comment, the XSL will just ignore it and not try to build a link to the issue tracker. This brings up the first modification you have to make.

If you want to use the functionality to integrate your issue tracking system with SourceSafe, you’ll have to use a comment like the one I describe above. In addition, you’ll have to change the line in the XSL file that builds the link to the issue tracker, since I’m going to guess that your URL to your issue tracker is not the same as the one I made up for the example.

Look for the line that looks like:

http://myIssueTracker/LookupIssue.aspx?Comment=

and replace it with the URL to your own issue tracker. The comment itself is appended to the end of whatever you specify here, so keep that in mind. Either your issue tracker will have to be smart enough to extract the identifier for the issue from the comment….or you’ll have to get fancier with the XSL to have it pass in only the ID number of the issue. Since my VB.NET skills are much better than my XSL, I chose to make the IssueTracker page the smart one. 🙂

CSS
The CSS file is nothing special, it just makes the display a little easier to look at.

The Final Product
An example VSS Reporter XML file shows how the three files work together to produce something that both looks nice (I think), and is useful.

If you look at the source for the XML file, you will see a line at the top that is not included in the XML file that is originally generated from VssReporter. This is a line that tell the XML processor where to find a XSL document to use (I hope I’m not lying about what is going on). In any case, you’ll need to add this line to the top of the XML file.

There’s also a ZIP file that contains the three files mentioned in this article. Just unzip all theee to the same directory.

Conclusion
Hopefully someone will find this useful. VssReporter is a really powerful (and free!) tool. I think Visual Studio 2005 Team System might make this unnecesarry in the future, but probably not for a while.

Two cool tools

Just want to post links to two cool tools that I’ve come upon:

The first is BCWipe which allows you to securly delete files, or entire drives. I haven’t used it, but I’ve talked to someone who has and they say it’s pretty cool.
http://www.jetico.com/

The second tool is Daemon Tools. This is a nice utility that allows you to mount ISO images as drives in Windows. I’ve got an ISO mounted right now, took a few seconds to click the icon in the tray, select my ISO image and then navigate to to my new “F” drive. Pretty slick.
http://www.daemon-tools.cc

MSDN Event – Visual Studio 2005

It was pretty good. Basically what I expected it to be, which was an overview of the new features available in Visual Studio 2005. One of the biggest advancements seems to be better data access, and more flexibility with how data is presented and bound to controls.

The DataSource wizard has been expanded too. You can now specify an external URL to fetch an XML file for a datasource, that was pretty neat. I’m not sure, but it also seemed that all the “auto-generated” connection strings were maintained in the web.config file auto-magically, even though the presenter was generating a new datasource on each page. There’s also a way to specify a stored procedure to use as the datasource. If this option is chosen, Visual Studio will read the parameters required and prompt you for where to get them (querystring, control, object, etc). Also pretty cool.

The other major feature is something called master pages which lets you specify a template-file for the entire site and control the layout with that file instead of having to keep track of includes all over the place. There’s also “skin” support that lets you define how each control should appear (i.e. all calendar controls should have a grey background, 12 pixel font, etc…). Unfortunately, the skin support doesn’t extend to regular HTML controls, so you can’t use it for things like an H1 tag…I don’t understand why not. This means that CSS is still required for these.

It will also validate the HTML for a particular browser, and will do it for section 508 compatibility if that’s required.

They didn’t cover much about Team System, which I was interested in, but they did give us a DVD of Team Foundation Server that we can install to check out the new features. They also gave us a DVD with all the presentation details on it, you are welcome to borrow mine if you want.