March 2005 - Posts

On the topic of deprecation, I came across this post today from Plip:

Do you use SqlCommand.Parameters.Add("@Name","Value"); ?

Well, you're in for a shock, it's been depricated in ADO.NET 2.0.
When you move to 2.0, you should instead be using: -

SqlCommand.Parameters.AddWithValue("@Name","Value");

While the depricated code will still compile it will throw a compiler warning: -

System.Data.SqlClient.SqlParameterCollection.Add(string, object) is obsolete: Add(String parameterName, Object value) has been deprecated.

Use AddWithValue(String parameterName, Object value).

The depricated method will not work in .NET v-Next (2.0 +).


Now, for the life of me, I could not fathom the reason for this change - even though I am a big fan (some call me neurotic) of naming conventions.  Well, here is the reason, as explained by Pablo Castro of the SQL Server team:

The problem is that both the C# and the VB.NET compilers will expose very weird behavior for this code:

command.Parameters.Add(“@p”, 0);

you may expect this to use the overload that takes an object and assign the value 0 to it, but instead it will pick the overload that takes a SqlDbType as the second parameter! In order to avoid this (and potentially others) ambiguity between the Add(string, sqldbtype) and Add(string, object), we deprecated Add(string, object) and introduced AddWithValue(string, object). In general, having multiple overloads where the distinguishing parameter type is “object” in one of them is a dangerous thing to do.

 

Posted by Jackie Goldstein | 6 comment(s)
Filed under: ,

For a project we are currently developing in .NET 2.0 / Whidbey, I needed to send email via a local  SMTP server.  At the time, I was working with the December 2004 CTP for Visual Studio.  When looking around for classes to send email, there seemed to be two different namespaces to deal with this:

System.Web.mail
and
System.Net.Mail

I was confused as to why this was the case, and why sending mail would be part of the Web namespace, but since searching on the web seemed to return more samples/disussions using the classes in that first namespace, I went for that one.  I couldn't get it to work, but that was probably because I was also dealing with some "Networking Hell" issues...

By the time I resolved my local networking issues, I had upgraded to the February 2005 CTP for Visual Studio.  When I went to run my code again, guess what I found ?  The System.Web.Mail.MailMessage  and System.Web.Mail.SmtpMail   classes were marked as deprecated and obsolete (with a message to use the System.Net.Mail classes instead) !   I guess I was right about where that functionality belonged...

Anyway, here is the (scrubbed) code, that works just fine:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim client As New SmtpClient("YourServer.YourDomain.com")
        Dim toAddr As New MailAddress("addressee@YourDomain.com")
        Dim fromAddr As New MailAddress("sender@YourDomain.com")
        Dim message As New MailMessage(fromAddr, toAddr)

        ccAddr = New MailAddress("guy@YourDomain.com")
        message.CC.Add(ccAddr)

        Dim bccAddr As New MailAddress("gal@YourDomain.com")
        message.Bcc.Add(bccAddr)

        message.Subject = "Hello World!"
        message.Body = "This message was sent from within my Project. "
        message.Body &= "If you don't believe me - go ahead and check the message header(s) !"

        client.Send(message)

    End Sub

Posted by Jackie Goldstein | 4 comment(s)
Filed under: ,

Efficens Software, the local Israeli representative of the ASP.NET framework and Code generator Iron Speed Designer, is running a contest for applications developed with that toolkit. 

If you can read Hebrew, you can read about the contest here.   If you notice the Renaissance logo on that page, it is because I have been asked (and agreed) to help judge the contest.

 

This hot off the presses announcement lays out the new pricing (and upgrade) structure for the different versions of Visual Studio 2005, as well as for MSDN subscriptions.  

 

 

Posted by Jackie Goldstein | 2 comment(s)
Filed under:
Version 2.0 of the popular  Updater Application Block  has just been released.  It has been enhanced and modified to work with other applications blocks in the Enterprise Library, which was released in January.   The Updater block allows you to get much of the functionality of Whidney's Click-Once Deployment in your VS 2003 applications today.  Check it out here and download it from here.
Earlier this week, I pointed out that mainstream support for VB6 is ending at the end of this month.  What exactly this means isn't necessarily all that clear :-) Fortunately, the new MSDN VB Strategist Brad McCabe has posted a very clear explanation. Brad is a great guy and is also very articulate - you can see this for yourself in his post on this topic
Posted by Jackie Goldstein | with no comments
Filed under:

Krishna has a good post on the basics of VS database projects, over on the VS Data Team blog.

I have always been a big fan of VS Database projects, and am constantly amazed at how few developers are aware of it. That is why I decided for my book to be one of the only books that dedicates an entire chapter to it.  Moreover, I convinced my publisher that this be the chapter we make available for free online.  You can see this chapter at

http://www.aw-bc.com/catalog/academic/product/0,1144,0672323435,00.html

or

http://www.amazon.com/gp/reader/0672323435/ref=sib_rdr_ex/102-5944358-0865766?%Fencoding=UTF8&p=S00R#reader-page

 

 

There is an interesting article in the New York Times today, describing the announcement by Electronic Arts, the world's largest independent video game maker,  that they will begin to offer overtime pay to some employees.  However, these employees will no longer be eligiable for bonuses or stock options.

Electronic Arts was in the spotlight a while ago, after a letter from an employee's wife appeared on the Internet, accusing the company of abusing its employees by forcing them to work tremendous amounts of (unpaid) overtime.  

So, what do you think ?  Which would you choose - overtime pay or bonuses and stock options ?

 

Posted by Jackie Goldstein | 6 comment(s)
Filed under:

A new February CTP version of Visual Studio 2005 Professional can be downloaded by MSDN subscribers.

New February CTP versions of the 2005 Express products are freely downloadable here.

Posted by Jackie Goldstein | with no comments

If you are still developing and/or maintaining VB6 applications, you need to be aware of the fact that mainstream support for VB6 from Microsoft ends this month.  Read about this and the post-mainstream options over here.

Please don't accuse me of using scare tactics to push people to VB.NET.   I am just trying to make sure you have the information.

More Posts Next page »