Friday, May 28, 2004

.Net application performance and scalability

I've got more reading to do... looks like a useful article.

Also, here's something totally unrelated but very, very interesting!

Tuesday, May 25, 2004

Delphi.net newsgroups

Here's a nice looking article from Borland on bdp.

And there are *heaps* of newsgroups on Delphi and .net ... what an idiot! These are the ones I've just subscribed to...

borland.public.delphi.aspdotnet.components.using
borland.public.delphi.aspdotnet.components.writing
borland.public.delphi.aspdotnet.general
borland.public.delphi.aspdotnet.ide
borland.public.delphi.com.interop.dotnet
borland.public.delphi.database.ado-net
borland.public.delphi.database.bdp
borland.public.delphi.database.dotnet
borland.public.delphi.internationalization.dotnet
borland.public.delphi.language.delphi.dotnet
borland.public.delphi.rtl.dotnet
borland.public.delphi.vcl.components.using.dotnet
borland.public.delphi.vcl.components.writing.dotnet
borland.public.delphi.winforms.controls.using
borland.public.delphi.winforms.controls.writing

Lots of reading to do...

Monday, May 24, 2004

A brave fellow...

Off topic for Delphi 8, but I've just been reading a guy's blog who is documenting his attempts at getting a startup software development effort off the ground. It's here: lachlan.gemmell.com. It looks as though it'll be worth following. Good luck to you, Lachlan!

Saturday, May 22, 2004

Some decent 'Delphi 8 does asp.net' links

There aren't many.. let me know if you find some!

This first one is by Zarko Gajic, who is the author of one of the asp.net demos on the Delphi 8 CD. He shows you how to get it going, and it's an invaluable resource once you do get it going, so do have a look here...

A Beginner's Guide to Asp.Net Programming for Delphi developers

Here's a borland section on IBM's site, with references to using Delphi 8 and DB2 together. I haven't read this :-)

Try GotDotNet.com for a great general purpose .net coding site. No Delphi 8 though.

Or, the Delphi Section on Experts Exchange might be worth a look if you are really stuck!

PS: Ever seen Microsoft advertising Borland products before?
The official Microsoft ASP.net page features Borland!

PPS: Somewhat more randomly, see this wiki on Delphi

Friday, May 21, 2004

For D8: Click anywhere & select with a web grid

I've converted Karl Moore's code for clicking anywhere on a web grid to select an item, and fixed a bug so that clicking on the currently selected row doesn't cause dramas. Here it is:


procedure TWebForm1.DBWebGrid1_ItemDataBound(
sender: System.Object;
e: System.Web.UI.WebControls.DataGridItemEventArgs);
var
btnSelect: Button;
begin
If (e.Item.ItemType = ListItemType.Header) Or
(e.Item.ItemType = ListItemType.Footer) Or
(e.Item.ItemType = ListItemType.Pager) Then
Exit;

If (e.Item.Cells[0].Controls.Count > 0) Then
begin
If e.Item.Cells[0].Controls[0] Is Button Then
begin
btnSelect := e.Item.Cells[0].Controls[0] as Button;
if (sender is DataGrid) and
(e.Item.itemindex = (sender as DataGrid).SelectedIndex) then
e.Item.Attributes['onclick'] := ''
else
e.Item.Attributes['onclick'] :=
Page.GetPostBackClientHyperlink(btnSelect, '');
End;
End;
End;

Thursday, May 20, 2004

Really, really good tips for asp.net grids

Check out these articles by Karl Moore for some really excellent tips on using data grids (microsoft ones, but a lot of it applies to bdp)...

Nine Steps to a Quick, Editable Web Grid

  • doesn't apply to bdp. In particular, it shows you how to implement buttons that do add, delete, forward, back, etc... I can't find *any* method of doing this in bdp so far (yowsa!)

  • essential if you want to get a usable grid using the .net DataGrid.



(where's part 1? No idea...)
The Big ASP.NET DataGrid Article, Part 2

  • How to Use HTML in a Web Grid

  • Using Hyperlinks in Your Web Grid

  • Dates, Currency, Percentages: Formatting your Web Grid Data

  • Looking Good: Color-Coding Your Web Grid

  • Little-Known Technique for Confirming Web Deletes (REALLY USEFUL)

  • Selecting Multiple Web Form Grid Items, Hotmail-Style (SURPRISINGLY TRICKY, GOOD TECHNIQUE)

  • Click Anywhere and Select, with a Web Grid (BRILLIANT!!!)





The Big ASP.NET DataGrid Article, Part 3

  • The Lowdown on Using Dropdown Boxes in a Web Grid (I haven't tried this, but hey, if it works then very cool)

  • Speedy, Personalized Web Data Binding

  • Quick and Easy Data Paging, with Your Web Grid

  • Sorting in Seconds, with Your Web Grid



Wednesday, May 19, 2004

Response to Quality Central Bug

This is a quality central "bug" (#7827) that I've responded to. It shows how to make the bdp components work for data-aware controls in asp.net where you are using an identity column in SQL Server.

-----------

Report from Delphi for .NET / Database [Add a report in this area]

Report #: 7827 Status: Reported
BDPDataadapter cannot update MSSQL table with Identity field
Project: Delphi for .NET Build #: D8 Update 2
Version: 8.0 Submitted By: Gerald Tavares
Date Reported: 4/6/2004 3:08:18 PM Report Type: Crash / Data loss / Total failure
Severity: Serious / Highly visible problem
Platform: 95, 98, 2000, NT, XP
Resolution: None Resolved in Build: None
My Rating: Not Rated - [Click Bar to Rate]

My Votes: None
Vote for Report
Overall Rating: 1.00

(1 total ratings) Total Votes: None

Description
Cannot update a MSSQL Database Table which uses a auto incr. identity field as a primary key. The update sql is incorrect and causes errors when the autoupdate or update is called,
Steps to Reproduce
None
Workaround
None
Attachment
None


Comments -- [Add a New Comment]

James Merrill at 4/15/2004 8:25:41 AM - [Reply to this comment]
Why no simple example of the incorrect SQL that's generated?


Micromet Software Developer at 5/19/2004 3:16:02 AM - [Reply to this comment]
1 - Drop a bdpConnection component on the form and connect it to your sql server. I'm connecting to database Northwind (I'll be using table Employees, which has an autoincrement key called EmployeeID)

2 - Drop a bdpDataAdapter on the form and click "Configure Data
Adapter..." (right popup menu, or select the adapter and click the hyperlink at the bottom of the object inspector). It'll link automatically to the connection component.

3 - In the "Command" tab, select "dbo.Employees" from the "Table" list box, check the "Optimize" checkbox, then hit "Generate". You'll now find the following 4 sql statements in the tabs below:

************************
SELECT:
SELECT EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, Photo, Notes, ReportsTo, PhotoPath FROM dbo.Employees

UPDATE:
UPDATE dbo.Employees SET EmployeeID = ?, LastName = ?, FirstName = ?, Title = ?, TitleOfCourtesy = ?, BirthDate = ?, HireDate = ?, Address = ?, City = ?, Region = ?, PostalCode = ?, Country = ?, HomePhone = ?, Extension = ?, Photo = ?, Notes = ?, ReportsTo = ?, PhotoPath = ? WHERE EmployeeID = ?

INSERT:
INSERT INTO dbo.Employees (EmployeeID, LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, Photo, Notes, ReportsTo, PhotoPath ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

DELETE:
DELETE FROM dbo.Employees WHERE EmployeeID = ?
************************

The Update and Insert statements are incorrect. To fix the update statement, you need to remove EmployeeID from the SET clause. To fix the insert statement, you need to remove EmployeeID from the field list, and remove one questionmark/comma pair from the VALUES list. So the fixed statements are as follows:

(nb: including blobs in the insert statement seems to break (causes Multiple Step OLE-DB errors). So, I've also removed the Photo and Notes fields).

************************
UPDATE:
UPDATE dbo.Employees SET LastName = ?, FirstName = ?, Title = ?, TitleOfCourtesy = ?, BirthDate = ?, HireDate = ?, Address = ?, City = ?, Region = ?, PostalCode = ?, Country = ?, HomePhone = ?, Extension = ?, Photo = ?, Notes = ?, ReportsTo = ?, PhotoPath = ? WHERE EmployeeID = ?

INSERT:
INSERT INTO dbo.Employees (LastName, FirstName, Title, TitleOfCourtesy, BirthDate, HireDate, Address, City, Region, PostalCode, Country, HomePhone, Extension, ReportsTo, PhotoPath ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
************************

Make these changes. You can check that the select statement works using the preview tab (it will, don't bother :-). In the Dataset tab, choose "New Dataset" (you can leave the default name if you have no preference).

4 - Click "OK". The adapter will be set up, and the new dataset will be created. Now, we need to go modify the adapter a little to make it work. In particular, you will see in both the insert statement and the update statement that the parameters in the parameters collection and the question marks in the insert or update SQL (in CommandText) are out of alignment. We need to fix this.

5 - Select the adapter, then in the object browser expand the "InsertCommand". Click on the Parameters collection, then click the build button "...". You will see that the first parameter is "EmployeeID". "Remove" this parameter (it's not actually present in your modified SQL). Also, remove Photo and Notes, as they have been removed from the SQL (see my note above in step 3). Then click "OK".

6 - Select the adapter, then in the object browser expand the "UpdateCommand". Click on the Parameters collection, then click the build button "...". You will see that the first parameter is "EmployeeID" and the last one is "EmployeeIDOriginal". You only need the latter, so select "EmployeeID" at the top of the list, and "Remove" it. Click "OK".

---

You are done! This adapter should now perform correctly for data aware controls such as the DBWeb controls, allowing insert, update and delete. Oh, and don't forget to go from design view to code view and back before doing any work with your DataSet tables collection, or it wont update itself correctly. Just click the tabs in the status bar for the .pas file, then back to Design. Weird, but true, and a very useful thing to do in most circumstances in D8. Saving a lot is also a really good idea!