Tuesday, May 08, 2007

Add Microsoft.Practices.CompositeUI.WinForms components to VS ToolBox

I installed Microsoft Pattern & Practices Composite UI Application Block (CAB) in my box (CBA_CS.msi). Howerver I could not find Microsoft.Practices.CompositeUI components in my VS Toolbox.

What I did is to Browser components from the dialog window and find the file (Microsoft.Practices.CompositeUI.WinForms.dll) in:

C:\Program Files\Microsoft SCSF\GuidancePkg\bin

Before I add these components, I create a tab in Toolbox "MSPP CompositeUI" and then add those components there.

Read More...

Saturday, May 05, 2007

DetailView/GridView/FormView and ObjectDataSource (APS.Net 2.0)

I found one thing interesting about web UI controls and ObjectDataSource control in APS.Net. The background story of this finding is that I tried to create a business logic layer (BLL) with a method to update some data in a database through those web UI controls.

My BLL, ProductsBLL, has a method UpdateProducts() with a list parameters corresponding some fields defined in a table Products, such as productName, unitPrice, unitsInStock, unitsOnStock, reorderLevel, etc. Somehow, I mistyped some field names in the parameter, for example, reorderLeve. That's OK. It is just a parameter for a cs class method.

I tried to configure my ObjectDataSource in an aspx page through ODS' wizard. The mistyped parameter name is auto-generated in aspx file as followings:

<asp:ObjectDataSource ID="ObjectDataSource" runat="server"
DeleteMethod="DeleteProduct" InsertMethod="AddProduct"
SelectMethod="GetProducts" TypeName="ProductsBLL"
OldValuesParameterFormatString="{0}" UpdateMethod="UpdateProduct" >
<DeleteParameters>
<asp:Parameter Name="productID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="productName" Type="String" />
<asp:Parameter Name="supplierID" Type="Int32" />
<asp:Parameter Name="categoryID" Type="Int32" />
<asp:Parameter Name="quantityPerUnit" Type="String" />
<asp:Parameter Name="unitPrice" Type="Decimal" />
<asp:Parameter Name="unitsInStock" Type="Int16" />
<asp:Parameter Name="unitsOnOrder" Type="Int16" />
<asp:Parameter Name="reorderLeve" Type="Int16" />
<asp:Parameter Name="discontinued" Type="Boolean" />
<asp:Parameter Name="productID" Type="Int32" />
</UpdateParameters>

In the web UI control(DetailView/GridView/FormView) section, I also used the same ODB control through GetProducts() methods in ProductsBLL, which returns a ProductTable with correct field names (for example, ReorderLevel). As a result, my aspx page got an expception when I tried to update a record. The exception's message is something like this:

ObjectDataSource 'ObjectDataSource' could not find a non-generic method 'UpdateProduct' that has parameters: ProductName, SupplierID, CategoryID, QuantityPerUnit, UnitPrice, UnitsInStock, UnitsOnOrder, reorderLeve, Discontinued, ProductID, ReorderLevel.

Notice that reorerLeve and ReorderLevel appear in the error message. The first one is the one defined in parameter list, and the next one is the field in UI control. They have to be matched! Otherwise, they both are used to make a method call to ProductsBLL, which results method not matching exception.

In addition to this finding, I find that the case is not sensitive for matching parameter names to UI field names for updating. I hope it would be better in a UI field definition where you can use a new attribute to specify which parameter is matched for updating/editting/deleting. By explicitly specifying a parameter, there would no need to couple ProductsBLL method's parameters to UI field names.

Read More...

Friday, April 27, 2007

DataSet 2.0 Issues

When I tried to use Visual Web Developer 2005 Express to compile a project with TypedDataSet, I got some warning message for compling. Basically, these warning messages are about some XML attributes for DataSet not being declared. For example:

Warning 2 The 'ParameterPrefix' attribute is not declared. G:\Datadc\Programming\ASP.Net\Data Tutorials\DT01\App_Code\Northwind.xsd 8 231 G:\...\DT01\

I googled solution to find out why and to remove these warning. Here is a link about this issue. In short, these attibutes are not defined in VS IDE's xsd file. I could to add these attributes there but it is not recommended. Steve Cheng from Microsoft Online Help said that you can ignore these messages and the build should be fine.

That's a good explaination for this issue.

Read More...

Tuesday, April 24, 2007

SQL 2005 Express error regarding generating new instances

Recently, I installed Microsoft SQL 2005 Express. Late on, I encounted a problem to open a database from Visual Web Developer 2005 Express. The error message is something like:

Generating user instances in SQL Server is disabled. Use 'user instances enabled' ...

I think the problem was caused by my installtion of SQL-Tools for adding Reporting services. I googled through web and found a solution to solve the problem from this link MSDN143684. Here are some steps:

  1. Open Microsoft SQL Server Management Studio Express
  2. Open a query and type in: Select * from sys.dm_os_child_instances. This will list all the users instances.
  3. Comment out the above line. Type in the commands:
sp_configure 'user instances enabled','1'
RECONFIGURE;
GO

Then open a project in VWD, and try to open a db again. The db was opened without error message.


I think there is a configuration in SQL to set either shared DB or new instances. If it is shared DB, no new instances are created.

Read More...

Monday, April 23, 2007

SQL Server Report Service Installation

Here are my nodes about installation of SQL Server Report Service.

My OS is Windows XP Pro. I installed .Net 2.0 Framework for learning ASP.Net purpose. Then When I needed SQL Server Report Service and Report Studio for creating report projects, I had to install IIS 5.1.

After I installed IIS5.1, then I installed SQLEXPR_ADV.exe which includes SQL Report Service. I got a program to browse //localhost/Reports/. The error message is "Failed to access IIS metabase".

The problem is caused by the fact that .Net 2.0 and ASP.Net 2.0 was installed before IIS. The solution is to run aspnet_regiis.exe in a cmd console (at .Net framework 2.0 folder):

aspnet_regiis -i

what this one does is to install and configure APS.Net 2.0 again. After that, the problem is solved!

One IIS related issue: do not use IP number in IP Adress (IIS configuration tool for Detault Web Site). It should be (All unassigned). I think the reason is that I don't fix IP and my IP is dynamically assigned through my router.

Through IIS configuration tool (from Control Panel|Administration Tools or MMC), you can set/add virtual directory, how to access the web page, and what is the default page. Many more settings can be done there.

Report Service configuration problem: use the tool from Microsoft SQL Server 2005|Configuration Tools|Reporting Service Configuration. Make sure all the settings are correct (checked V). I did not set Reporting Service Virtual Directory because it was checked V. However, it was not set and empty. After I accepted the default settings. My SQL Reporting Service page (//localhost/Reprots/) is opened!

Read More...

Thursday, January 19, 2006

Array var in Managed(.Net) C++

In managed C++, define an array variable for a managed class, in syntax, is different from standard C/C++. For example,


using System::Drawing;
//...
array<PointF, 1>^ pointsF = gcnew array<PointF, 1>(100);
// PointF pointsF[100]; // is wrong
// PointF pointsF[] = gcnew PointF[100]; // is wrong
//...
pointsF[0].X = 11.23f;
pointsF[0].Y = 0.54f;


where PointF is a structure defined in System::Drawing namespace.

For String class, you have define an array of String as:


array<String^, 1>^ s = gcnew array<String^, 1>(10);
//String^ s[] = gcnew String^[10]; // wrong again


The general format to define an array of type is:


[qualifiers] [cli::]array<[qualifiers]type1[, dimension]>^ var =
gcnew [cli::]array<type2[, dimension]> (val[,val...])


See MSDN on Array Keyword

Read More...

Wednesday, January 11, 2006

Windows Installer Problem

Some times I got anoying error messages when I tried to open some applications such as VB6.0. The message is like a dialog window with the message:

Setup is aborting now. Cannot detect file: mediainfo.ini


This is caused by Windows Installer when I tries to find some files based on Registry settings. For example, I removed some binary files which were installed by Windows Installer but I could not find Uninstaller for those files or I could not run uninstaller successfully.

Here are some steps to avoid these messages:

Locate missing files

  • Open Event Viewer from Administration Tools.
  • View property for the most recent warning messages in Application node, and make a note of missing file, for example, "C:\MyTools\Bin\Interop.Utility.dll".
Search for Registry settings for missing files
  • Open RegEdit
  • Locate to "My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer"
  • Search for the file with path found above. Note, do not include drive like "C:" in the search string.
  • You should find a key like this: "...\UserData\S-1-5-18\Components\D1311F8CC3D78BB42BCF6A". Under this one you will find a key Item with a value like "C?\\MyTools\Bin\Interop.Utility.dll".
Change Reistry Settings
  • What I do first is to find the missing files and copy them to a folder like "C:\MissingFiles\Installer\"
  • Then I change the registry key item's value to "C?\MissingFiles\Installer\Interop.Utility.dll".
After I change all the registry items for these missing files, I will not get warning message any more.

I am not sure if I should remove these registry keys or not. For safe purpose, I try to find missing files and udpate registry instead.

Read More...

Friday, November 04, 2005

WMI class

Here are two entries I posted to my Yahoo blog, regaring the problem of using WMI class to query memory stat and a solution in case of memory > 4GB.

Problem of using WMI class to query memory stat when memory size > 4GB.

A solution of getting memory stat.

I change to Blogger to continue my posting because I found that Yahoo's blog does not have tag feature.

Read More...

Friday, May 21, 2004

My First Blog Entry

Blog is not new for me, but I have never tried to set up one. This is my first try. I don't know how long I'll keep it. Good start!

Read More...