Rants Tagged with “.NET”
Chris Sells asked me today if there was a re-usable connection string user interface that I knew of. I'd heard that you could use the dialog from Visual Studio, but I had to dig in and remember how. I've put together this quick and dirty example for downloading.
The trick is two fold:
- You need to add Microsoft.Data.ConnectionUI.dll and MicrosoftData.ConnectionUI.Dialog.dll assemblies to your project. (they are found i the VS2005/Common7/IDE directory)
- Next you need to construct the dialog like any other, but first fill it with the standard providers as well as use the static Show method:
DataConnectionDialog dlg = new DataConnectionDialog();
DataSource.AddStandardDataSources(dlg);
if (DataConnectionDialog.Show(dlg) == DialogResult.OK)
{
textBox1.Text = dlg.ConnectionString;
textBox2.Text = dlg.SelectedDataProvider.DisplayName;
}
The sample includes how to find out if the user wants to save the provider and skip that part of the dialog everytime. Let me kow what you think!
I am delving into WCF and AJAX (not at the same time) lately so I wanted to see if they were compatible. According to this whitepaper on ASP.NET (follow the link and scroll down to "Support for WCF Web Services"), the RTM of AJAX does not support WCF. It seems they removed it so they could make it work better in a later release. The promise is that by the Orcas release of VS, they will be compatible.
This further cements my opinion that releasing .NET 3.0 without FULL tool and compatibility is nonsense. Without a good across the platform support (e.g. WCF and ASP.NET stack working well together), a workable WPF editor (Cider is horribly broken currently...change the default editor for XAML to XML, you'll be happier), and projects that actually compile out of the box (WPF projects don't compile currently without some hand-editing of the XAML). Microsoft has always been about tools more than technology, that's why I've been with them so long. If we need to cruft together a bunch of installs to make stuff work, I'd be doing that in Java and Linux.
It looks like most .NET 3.0 development should wait until late 2007 when Orcas ships...but that's just my opinion...
Until The ServerSide .NET can post the sample code, I am posting it here
- Sample Code
Thanks to Thomas Carpe for reminding me that I posted the wrong code! Fixed!
After reading this interesting article by Pablo Castro, I have to assume that the real purpose of using Async Execution is for specific use-cases when you need to fire off multiple concurrent queries in service situations (e.g. ASP.NET, Web Services or Windows Services).
There are several interesting observations in this article:
The first one i'd like to point out is in the "Keeping WinForms Applications Responsive" section. He states explicitly that the BackgroundWorker is a better solution than using Async. This means that you should avoid using it in UI-based apps (probably WinForms and WPF).
Another observation is detailed in this quote from the article (emphasis added):
"Note that if you know you'll use a given connection object with synchronous commands only, it's better not to include the async keyword in the connection string, or alternatively include it but set it to false. Execution of synchronous operations on connections that have asynchronous operations enabled will have noticeably increased resource utilization."
This leads me to two conclusions:
- Async connections won't be pooled with non-async (since they have different connection strings).
- You will need to weigh the higher resource utilization against the performance improvement of concurrent query execution to determine whether to use it.
Also, since you can manipulate a resultset from each concurrent query at the same time, it seems that the async keyword also turns on MARS on the connection, but I do not have any evidence of that...just a suspicion.
My advice? Take time and read (carefully) what Pablo Castro has to say in the article and only use the Async functionality when you have a very clear case of concurrent execution in a service environment (ASP.NET, Web Service or Windows Service).
Feedback is encouraged...
The
ADO.NET Team has a blog (in case you aren't already subscribed, do it now). They
blogged today about the performance considerations of accessing Large Objects (LOBs) when using SqlDataReader. Read it now and bookmark it. This is a great
post!
My newest DevSource article is live. It is about how to write Windows Live Messenger Addins with .NET. Check it out
I've blogged before about issues with the SqlDataSource. I've crufted up an example of the problems that can be downloaded here (with usual caveat of changing the connection string in the web.config to point to a DB with the Northwind database).
There are three basic issues:
- The problem is that if a database allows nulls (and a specific row has an NULL) then the automagically created queries in the SqlDataSource will affect zero rows. So data loss can happen without alerting the user.
- The other related issue is that if an Update fires and affects zero rows it is swallowed unless the user handles the DataSource.Selected event.
- Lastly, if your query includes SQL Server Timestamp fields, the SqlDataSource designer doesn't know how to handle it correctly (either by inserting it into the Keys field of the control, or that it isn't a varbinary field).
I want the ASP.NET team to use the SqlCommandBuilder so that we have a common SQL Generationh platform so problems fixed in one place don't re-rear their heads.
In general you can get around these issues by hand-crafting your own SQL (or preferrably using Stored Procs) and handing the Updated and Deleted events in your DataSources. The problem with this is that since SqlDataSources seem to be a good RAD-type tool, then they should work in most databases 'out of the box' and they don't.
Any comments on the code or this issue are certainly welcomed!
Big thanks to Scott Guthrie in championing the Web Application for ASP.NET 2.0! I love using the old ASP.NET model (instead of the ackward Web Site project). I have now completely converted to the new format and I am very happy with the way it worked in almost every way.
+1
(If anyone notices anything not working, please feel free to send me an email here).
In cooperation from Dunn Consulting and Training, we will be offering a new five-day course on Enterprise Data Architecture. The course will teach best practices from the ground up when it comes to implementing data solutions with Microsoft .Net tools and technologies.
We are running a Beta class of this course on September 18th - 22nd for the substantial discount price of $1,750. For complete information see the Dunn Training site:
http://www.dunntraining.com/EnterpriseDataArchitecture.htm
I've gotten a couple of questions about a quick little Windows Messenger Add-In I wrote after watching the Channel 9 Video about how IM works. You can get the information on how to write your own add-in for Windows Messenger at Katie Blanch's Blog:
I like the design in that it can do some fun stuff, but not so powerful that I will have bots start talking to me. Security seems to be pretty solid and when an add-in is talking to you (instead of the person) Messenger makes sure you know it. I was able to write a quick add-in in about 10 minutes that sent a message to people that contacted me while I was in a full screen app (VPC or WoW) that I will be back in a minute.
Take a look if you have time.