Tuesday, November 28, 2006

Clearing up few points of common confusion about the next version of ADO.NET... read more

[A DevLife post]

Tuesday, November 28, 2006 8:10:21 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, November 06, 2006

Getting SqlDependency to work takes an enormous amount of orchestration up front - especially with regards to SQL Server permissions. Steve ran into a problem which made SqlDependecy work only intermittently. He finally got to the bottom of it (was related to the dbo owner) and has blogged about it here.

Monday, November 06, 2006 7:41:07 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, September 08, 2006

I was recently involved in an ASPAdvice thread about close and dispose - an age old .NET debate. (Okay, the "age old" part is relative.)

As backup, I quoted the msdn documentation that says "close and dispose are functionally equivalent" and someone pointed out not to believe everything I read and that in .NET 1.1, it was known to be "broken".

With a hint from Angel Saenz-Badillos from the ADO.NET team, I opened up reflector to find proof that dispose will close as well . See the guts of dispose and close below.

I don't see anythingn wrong with still calling close *and* dispose, just to be completely explicit. I've seen people do it inside of using blocks with a connection, even though the end of the block will call SqlConnection.Dispose which in turn calls close. So it's redundant. And you would think that C# programmers would celebrate the use of less code.

Are there truly known cases where this fails?

This is SqlConnection's Dispose method:

protected override void Dispose(bool disposing)
{
      if (disposing)
      {
            this._userConnectionOptions = null;
            this._poolGroup = null;
            this.Close();
      }
      this.DisposeMe(disposing);
      base.Dispose(disposing);
}
And just for fun...SqlConnection's Close method. Don't get confused by that Dispose at the end.
That's for a different object, not the actual connection.
 
public override void Close()
{
      IntPtr ptr1;
      Bid.ScopeEnter(out ptr1, "<sc.SqlConnection.Close|API> %d#", this.ObjectID);
      try
      {
            SqlStatistics statistics1 = null;
            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                  statistics1 = SqlStatistics.StartTimer(this.Statistics);
                  lock (this.InnerConnection)
                  {
                        this.InnerConnection.CloseConnection(this, this.ConnectionFactory);
                  }
                  if (this.Statistics != null)
                  {
                        ADP.TimerCurrent(out this._statistics._closeTimestamp);
                  }
            }
            catch (OutOfMemoryException exception3)
            {
                  this.Abort(exception3);
                  throw;
            }
            catch (StackOverflowException exception2)
            {
                  this.Abort(exception2);
                  throw;
            }
            catch (ThreadAbortException exception1)
            {
                  this.Abort(exception1);
                  throw;
            }
            finally
            {
                  SqlStatistics.StopTimer(statistics1);
            }
      }
      finally
      {
            SqlDebugContext context1 = this._sdc;
            this._sdc = null;
            Bid.ScopeLeave(ref ptr1);
            if (context1 != null)
            {
                  context1.Dispose();
            }
      }
}
Friday, September 08, 2006 1:21:41 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, August 21, 2006

Read all about it here...

[A DevLife post]

Monday, August 21, 2006 1:49:17 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, June 24, 2006

Okay - the post title is meant to be facetious, but this blog post on my DevLife blog is some early thoughts on the ADO.NET vnext whitepapers and some of the ORM community's reaction to them as well. [read more ...]

[A DevLife post]

Saturday, June 24, 2006 8:11:46 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, June 16, 2006

Thanks to Fabrice for pointing out that the whitepapers for the next gen ADO.NET are online. I am really excited abut this stuff.  I'm printing them out for my airplane reading. (Which is wholly unlike me!) I better get back to packing!

Friday, June 16, 2006 8:02:11 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, June 12, 2006

I am still in Vermont and missed Pablo's ADO.NET 3.0 talk. Kent Tegels was there though... [read more ...]

[A DevLife post]

Monday, June 12, 2006 11:34:13 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, April 12, 2006

Though I have the necessary permissions for using SqlDependency almost memorized (as well as documented in my presentations and my new CoDe Mag article on Query Notification), I tend to forget that when using the lower level SqlNotificationRequest, that you need permissions to send and receive on your custom services and queues.

Here's how to do that and here is the MSDN Documentation on the same.

In this example, the ASPNET account is the one for IIS5 that I have set up in my SQL Server. Use whichever account is going to be accessing the services and queues.

GRANT RECEIVE ON MyNotifQueue TO ASPNET

GRANT SEND ON SERVICE::[MyNotifService] TO [ASPNET]

 



Don't Forget: www.acehaid.org
Wednesday, April 12, 2006 9:00:06 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Thursday, March 16, 2006

Someone asked me about ADO.NET indexing which encouraged me to write about some of the amazing results of some performance tests I have done comparing VS2003 and VS2005's DataTable indexing. [Read more...]

[A DevLife post]



Don't Forget: www.acehaid.org
Thursday, March 16, 2006 9:53:59 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, February 24, 2006

Sahil's teaser video for his ado.net 2.0 video training course is great. Clearly a guy who loves data access and has an enormous reverence for data. But watch the video all the way through as you will surely get a great laugh at the end!



Don't Forget: www.acehaid.org
Friday, February 24, 2006 5:07:41 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, February 19, 2006

Did you hear that the ADO.NET 2.0 indexing engine screams? But not in the way I was expecting! [Read more ...]

[A DevLife post]



Don't Forget: www.acehaid.org
Sunday, February 19, 2006 2:11:33 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, January 29, 2006

There's a cool new .net 2.0 feature I didn't know about until I needed to do this a few days ago. If your application has FullTrust, you can use the System.Data.Sql.SqlDataSourceEnumerator to get a list of available SQL servers (2000 and 2005 only). The query returns a DataTable which you can just attach to a combobox or drop down list.

 Dim instance As SqlDataSourceEnumerator =      SqlDataSourceEnumerator.Instance
 Dim dt As DataTable = instance.GetDataSources()

Remember, though, this requires the assembly to have full trust. There is not a specific permission you can apply to use this otherwise.



Don't Forget: www.acehaid.org
Sunday, January 29, 2006 1:50:05 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Thursday, January 12, 2006

I went around and around (and dragged poor Sushil Chordia and blogless Leonid Tsybert along for the ride) with an access permission problem that my ASPNET account was having when trying to do SqlDependency.Start. All of the correct permissions (listed below) had been applied to the account, which could be verified with sp_helprotect,NULL,ASPNET

Finally, I just gave up and removed the ASPNET account from SQL Server in its entirety and recreated it with the necessary permissions and everything worked just fine.

Though I'm very frustrated not to have figured out what was causing the problem, I'm satisfied in knowing that there is a solution (remove & recreate.)

Here, as listed in Sushil's fantastic blog post from late September, which listed all of the RTM changes for Query Notification, is how to set up the perms.Note that this is for IIS5 whereas in IIS6 you would use the NT Authority\NetworkService account.

All of this is run against the database that you want the perms for, not in Master.

sp_grantlogin 'myMachineName\ASPNET'     --this gives the ASPNET account login access to SQL Server
sp_grantdbaccess 'MyMachineName\ASPNET', ASPNET   --this gives the login access to the database with the "nickname" ASPNET

GRANT CREATE PROCEDURE to ASPNET
GRANT CREATE QUEUE to ASPNET
GRANT CREATE SERVICE to ASPNET
GRANT REFERENCES on CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] to ASPNET  --note that the schema is case sensitive!
GRANT VIEW DEFINITION to ASPNET

The above are to call Start(), to do the actual notifications, you need:

EXEC sp_addrole 'sql_dependency_subscriber'
GRANT SUBSCRIBE QUERY NOTIFICATIONS TO ASPNET
GRANT RECEIVE ON QueryNotificationErrorsQueue TO ASPNET
GRANT REFERENCES on CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification] to ASPNET
EXEC sp_addrolemember 'sql_dependency_subscriber', 'ASPNET’
GRANT SELECT TO ASPNET



Don't Forget: www.acehaid.org
Thursday, January 12, 2006 4:29:39 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, November 18, 2005
I have had to grok and also explain Service Broker as part of my work and presentations on Query Notification. I kind of get it on the surface but do not get it deeper down and will probably never write t-sql to work with it anyway. I was very happy in talking with a SQL Server guru recently who also thought Service Broker was really hard to understand. If it's hard for a SQL Server whiz, then I'm not going to beat myself up about it anymore - until of course, I need it more directly than just through Query Notification (via ASP.Net or ADO.Net).

Don't Forget: www.acehaid.org
Friday, November 18, 2005 4:42:37 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
Jon Hassel was the technical editor of Sahil's new book and is obviously very pleased to have participated on such a great book!

Don't Forget: www.acehaid.org
Friday, November 18, 2005 1:39:46 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, November 09, 2005

In my Sql Query Notification session, I had an odd problem. My SqlCacheDependency demo did not receive it's invalidation. This happened when I set it up in code and also when I set it up in <%Cache> directive on the page. This is a demo that I have done many times in the past year so I was not only mystified, but a little heartbroken.

The only thing that was different was that I had run a SqlRequestNotification demo right before it. This demo listens for the notification on a separate thread.

Now playing with it some more, I see that after I end the first demo (SqlRequestNotification) and start up the SqlCacheDependency... when I change the data, I hit the event handler in the first demo. So that was still hanging around.

What I think is happening is that even when I end the demo and close the page, the file based web server is still there (I can even see it in my system tray right now). The app was still alive and the listener was still listening. So now I am going to have to dig further into SqlRequestNotification in a real scenario even though it is not something I think I will not use frequently. If it wasn't the web app, it is likely that in this non-best practices demo code, I am not disposing enough things (though the listener's main task is within a using statement) or something along those lines. Most importantly, it is not a likely scenario to run these two things back to back and therefore this is an unusual problem that I encountered.

I couldn't really take the time to think this through in the session and probably wouldn't have come to this conclusion under the small pressure of the clock ticking and those expectant faces in the audience. So I just had to go with "I promise you this works! This is the right code for you to use..." and move on to wrap up the session.



Posted from BLInk!
Wednesday, November 09, 2005 10:36:20 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, November 06, 2005

The rules for using Query Notification have finally settled after evolving through all of the betas and ctps. Here they are copied and pasted directly from the msdn help files:

Applications that use query notification features need to take into account the following special considerations.

Valid Queries

Query notifications only support certain Transact-SQL statements.

First, to support notifications, queries must not contain:

  • Derived tables.

  • Rowset functions.

  • The UNION operator.

  • Subqueries.

  • Outer or self-joins.

  • The TOP clause.

  • The DISTINCT keyword.

  • A COUNT(*) aggregate.

  • AVG, MAX, MIN, STDEV, STDEVP, VAR, or VARP aggregates.

  • User-defined aggregates.

  • A SUM function that references a nullable expression.

  • The full-text predicates CONTAINS or FREETEXT.

  • A COMPUTE or COMPUTE BY clause.

  • Aggregate expressions if GROUP BY is not specified in a select list. If GROUP BY is specified, the select list must contain a COUNT_BIG(*) expression, and cannot specify HAVING, CUBE, or ROLLUP.

  • An INTO clause.

  • Conditions that will preclude results from changing (e.g. WHERE 1=0).

  • FOR BROWSE (or be running with SET NO_BROWSETABLE ON).

  • A READPAST locking hint.

Second, queries must not reference:

  • Temporal tables or table variables.

  • Tables or views from other databases or servers.

  • Any other views or table-valued functions.

  • Any system tables or views.

  • Any nondeterministic function, including ranking and windowing functions.

  • Any server global variables.

  • Any Service Broker queue.

  • Synonyms.

Finally, queries must reference a base table or view.

Rapid Updates

An application that uses Query Notifications must take into consideration cases where a notification occurs immediately. When data is changed on the server, a notification message will be sent to the appropriate Service Broker queue. Applications need to reregister to receive additional notifications. Therefore, if a data set is updated quickly by multiple applications, an application could receive a notification, retrieve the data, and then get another update notification almost immediately after the cache has been refreshed. Applications that use Query Notifications must be written to take this case into account. If an application uses data that is constantly updated, another strategy for caching data may be more appropriate.

Transactions

If multiple modifications are made to a set of data with a registered notification request, and those changes occur within a transaction, only a single notification event will be sent.

Service Account for SQL Server

An application will not receive notifications from an instance of SQL Server that uses the Local System account as the service account.



Posted from BLInk!
Sunday, November 06, 2005 5:24:09 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
I'm reviewing my demo that I built for caching data at the middle tier that is part of my query notification session at DevConnections next week - and had a funny moment. I wrote this a while ago and am just revisiting it and felt pretty impressed with myself when I saw how it worked. It's a little complex but now it seems simple. I used what I learned watching Pablo Castro's DAT320 session that I have on my TechEd 2005 video as the basis for this. I watched him do it in the video and translated the concepts into a simpler version using VB. I had to deal with some differences in the way static variables interact with shared methods in VB that had me pretty confused (as I'm not so adept with that)  - very different than how Pablo did it in his C# demo. But I did get it working and now have a big satisfied grin on my face. And next week I get to share (show it off) with attendees of my session.

Don't Forget: www.acehaid.org
Sunday, November 06, 2005 4:11:39 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, October 22, 2005

If you are doing an UpdateBatch with ADO.NET 2.0 and do not explicitly set an UpdateBatchSize parameter, this will default at one - meaning that one row will be sent at a time to the server for updating. Whatever other number you set it at is the number of rows that will be sent in a batch and of course you need to consider a variety of factors when choosing this number (such as network latency, how many columns are in the table, etc - bigger is not always better!) This is hardly new info at this point, but there is one other setting - zero. I am listening to Pablo Castro's ADO.NET 2.0/SQL Server integration talk from TechEd (DAT320) and laughing because he says (this is not a direct quote - I am paraphrasing) "If you set it to zero, there will be no limit to the number of rows....[pause]...which isn't really very good for performance .. [pause].. I don't really know why we put it there, but...[you can practially hear him shrug his shoulders] .. we did". Pablo can totally get away with this... the audience laughs with him and he moves on. Funny how if some other teams said something like this this, they would probably have many detractors. ADO.NET is just a happy API!



Don't Forget: www.acehaid.org
Saturday, October 22, 2005 1:48:51 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, October 14, 2005
Here is an excellent article on using ADO.NET and SQL CLR inside of SQL Server: Managed Data Access Inside SQL Server with ADO.NET and SQLCLR. Besides the obvious code, there are things you should be aware of such as context connections, how transactions work and most importantly, when not to use ADO.NET in the SQL CLR. The article is by the ADO.NET master himself, Pablo Castro, who is the Technical Lead on the ADO.NET team.

Don't Forget: www.acehaid.org
Friday, October 14, 2005 12:27:31 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, October 09, 2005
There was a problem with SqlDependency pre-Beta2 which created headaches for anyone trying to use it as a non-admin. It also created headaches for programmers at Microsoft who were in charge of it. They finally reworked some of the plumbing in order to get past the permission issues. In this DataAccess blog post, Sushil Chordia not only explains why the problem existed, but what they did to fix it, how to use SqlDependency now (most changes were in the plumbing, but you do have to do some minor changes in your code) and also what permissions are necessary in SQL Server to get it working.

Don't Forget: www.acehaid.org
Sunday, October 09, 2005 2:58:57 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, September 25, 2005

One of the fun brain teasers that was asked in my What's new in ADO.Net 2.0 talk today at Code Camp 4 in Boston was if it was possible to create a DataReader from the original values of a DataTable using the new CreateDataReader method.

Although there isn't a direct way to do it, I came up with a simple way to achieve this.

Basically you get a dataview of the table. Set the RowsStateFilter to OriginalRows. (That's available in 1.x also). Then use the new DataView.ToTable method to create a new table. Lastly, use the Table.CreateDataReader to create a DataTableReader.

dim dv as DataView=myTable.DefaultView
dv.RowStateFilter = DataViewRowState.OriginalRows 
dim dtNew as DataTable=dv.ToTable()
dim dtr as DataTableReader=dtNew.CreateDataReader



Don't Forget: www.acehaid.org
Sunday, September 25, 2005 8:47:24 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, September 06, 2005

In my What's new in ADO.NET 2.0 talk, I have one slide and three quick demos on Query Notifications. For DevConnections, I am doing a whole talk on the topic. I was a little worried about filling up an entire session on the topic, but I have learned so much about Query Notifications, caching and SQL Server Service Broker, that I could go on and on about it.

For anyone who has started working with this fantastic new result of collaboration between ADO.NET and SQL Server developers at Microsoft, there are some post-Beta2 changes you should be aware of.

Most importantly, it will, indeed, be possible to use query notifications (easily) when running as a non-admin. Phew!

Also, the plumbing has changed. Through Beta2, notifications come back through either TCPIP or HTTP. This was creating the permission issues above. Now It will be necessary when using SqlDependency or SQLCacheDependency, to do an application wide SqlDependency.Start, which will open up a SQL Connection for the notifications to come through.

Currently there are some settings that need to be tweaked which we haven't figured out yet so I wouldn't bother trying to use this post Beta2 anyway. After many many (many) hours of experimenting, I am determined that there is some setting in SQL Server that we are missing. (And I don't mean enabling service broker on the database). The experimenting pays off with a deeper understanding of how things work.

As soon as I find out the magic combo of settings, I will be sure as ___ ;-) to post them here!

Update: My old friend CompatibilityLevel had come back to bite me in the rear end - and hard. I was using the pubs database. Steve Smith was having the same problem and using the Northwind database. I was using a new install and therefore not inheriting my pubs db where I had changed the setting for pubs to 90. I thought the issue was gone, but it wasn't.

So, though this deserves it's own blog post - remember you can check and set the compatibility level. You need 90 for working with Notification Query. I wonder if Service Broker has the same requirement.

sp_dbcmptlevel yourdatabasename

will tell you what the level is.

sp_dbcmptlevel yourdatabasename,90

will set it to 90.

Thanks to Sushil Chordia and Leonid Tsybert at Microsoft for their help with this!!

 

Don't Forget: www.acehaid.org

Tuesday, September 06, 2005 4:34:34 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, August 24, 2005

I recently received my TechEd 2005 conference DVDs which allow me to now catch up on many awesome sessions I was not able to attend while I was there. One session in particular that I just watched which is filled with great prescriptive information - not just how to , but when and why - is “DAT421: Client and Middle Tier Data Caching with SQL Server 2005” by Pablo Castro and Steve Lasker. One of the gems in there is this slide by Pablo, who is the PM on the ADO.NET team. [read more]

[A DevLife post]



www.acehaid.org
Wednesday, August 24, 2005 9:42:24 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, August 22, 2005

If you have ever used a SqlDependency in .NET 2.0, have you ever inspected the object before you execute your command?

In the object is a property called Callback ID. When I am running both the .NET code and SQL Server on the same machine or same network, this is set up to traverse back through TCPIP.

 "<MachineAddress>tcp://192.168.0.5:58343</MachineAddress>
<AuthType>None</AuthType>
<Key>a55f6539-5d30-4e67-b87a-a4e3ebb85131</Key>" 

192.168.0.5 is the address of the client machine and 58343 is one of the ports that SqlDependency is pre-defined to use. This is using Beta2 bits and I expect that this will change when I load the next CTP onto my computer. But for now, it's interesting to see.

I am now curious to see what the message looks like when it arrives in SQL Server's clutches, before it strips out the query and sends it off to be processed.



www.acehaid.org
Monday, August 22, 2005 5:00:42 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, August 09, 2005

I will get this to work! Currently I have to be logged in as an administrator to get SqlDependency to work. I have tried giving a variety of notification related permissions in the database to my lowly user login, but to no avail.

I just came across this - oh, what a shocking place to find the info  in the documentation for VS2005! :-) I must have come across it early on before I understood what the heck I was reading. Now it makes sense to me though and these looks like some good clues!

Security

The dependency infrastructure includes a client-side listener that is contacted by the server to send notifications. This listener is protected by Code Access Security attributes and by authentication. For more information, see SqlNotificationPermission Class and SqlNotificationAuthType Enumeration.

Code Access Security Assertions

The listener infrastructure enables the listener to listen on TCP ports or HTTP ports depending on which system is running. To use the listener, which is necessary to use SqlDependency, the caller must have SqlNotificationPermission. The use of the SqlNotification request is independent of the dependencies and listener infrastructure on the client. Therefore listener permission is not required.

I know that I did grant Query Notification permissions to my lowly user account ( as a test) and also QueryNotifcationErrorsQueue as the exception instructed me to. I also opened up some of the recommended array of ports (which at the time was supposed to be a bit of a hack fix).

Still I never got it working.But I am definitely adamant about succeeding at this! So I will be sure to post my solution when I get there.



www.acehaid.org
Tuesday, August 09, 2005 9:24:39 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

One of the many topics I cover in my ADO.NET 2.0 talk is about the ability to modify the rowstate of unchanged rows with SetAdded or SetModified. If you have never been in a position where you wished like crazy that you could change the row state, or if you don't understand the semantics of DataRowState and how importing, adding or merging affects it, then these features don't really make a lot of sense.

Moving datarows around is not the only time I imagine you might have a need to affect the rowstate, but I wanted to just point out a few of the nuances of moving rows.

When you add rows using the DataTable.Rows.Add method, the rowstate of the added row will be Added (regardless of what its' original state was).

When  you import a row, the row's current state will be imported with it.

Merge is the same as import in regards to the affect on rowstate. Merge just imports a whole bunch of rows at once. So, it, too, persists the row state.

In the demo I have for SetAdded and SetModified, I have two sets of data. One dataset coming from a local database and another coming form a web service. I append the 2nd set of data to the first using the Merge function. Then the next step is to update my database and I want the newly merged data to go in the database as well as any changes to the original set of data. In the demo, all of those new rows from the web service do not get uploaded because their rowstate was "Unchanged". By using the Merge function, the rows were not flagged as "Added". This definitely is a surprise to some people when I do that demo because many do not grok the differences between Import/Merge and Add.

Here is a Data Points column by Joseph Papa from a 2003 issue of MSDN Magazine that explains how rowstate is affected. After reading that, it might make more sense why having the ability to affect the state of the rows is a useful thing. SetAdded and SetModified are two functions that you do not want to use unless you definitely know what you are doing.



www.acehaid.org
Tuesday, August 09, 2005 7:54:49 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 

I have not looked at all at the strongly typed datasets in .NET 2.0, so when Dave Burke started talking about DataTableAdapters last night, I thought he was talking about the DataTableReader. He was pretty adamant. We gave him a hard time  - it was late, we were punchy. What can I say. In reality,  I just had no clue. So Dave now has a post explaining all about the TableAdapter here!



www.acehaid.org
Tuesday, August 09, 2005 6:57:00 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, June 15, 2005
 Wednesday, June 08, 2005

I had someone ask an ADO.NET question last night that I just couldn't answer. It was a little more about distributed transactions which I have little experience with. So I had him type the question into Notepad on my laptop. Twenty minutes later, I saw Pablo Castro and had him type the answer so that I could get it back to Ziga without misinterpretation. Pablo also filled me in so that I understood the question as well as the answer. I thought I would share it here....

Q. What's the performance difference when using a transaction scope vs. assigning transactions to connections & sqlcommands the ado.net 1.1 way?

A. Short answer (there is much more to this topic)

If you're using System.Transactions against a SQL Server 2005 server, then the cost is more or less the same (assuming that you don't bring more than one Sql connection to the scope).

On the other hand, if you're hitting a SQL Server 2000 server, then System.Transactions will be more expensive because we'll "promote" the transaction (into a distributed transaction) even for the very first connection.



Posted from BLInk!
Wednesday, June 08, 2005 6:13:28 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, May 25, 2005

Well that was fun. I just did a webcast with DCC Glen Gordon on MARS, a new feature of SQL Server2005 that is leveraged in ADO.NET 2.0. (I'll post a link to the on-demand version of it when it gets posted)

Although I have looked at, experimented with, presented on and written about MARS previously, this was the deepest I have gotten into it. Glen and I had a lot of interesting talks in advance of doing the webcast. One thing that I really have learned a lot more about is transactions, where we can benefit from MARS the most.

Doing a webcast is fun, but for me the downside is not having the interaction with a group of people that you get doing a live presentation. You can see on people's faces when something is confusing, or if you are going on a little too long about something you may think is really fascinating, but they don't. :-) and make adjustments as you go along.

MARS is very powerful, but it's so important to understand what it does and how it works before you start leveraging it. Otherwise you have the potential, as Christian Kleinerman says in his excellent MARS article, to really shoot yourself in the foot!



http://www.AcehAid.org
Wednesday, May 25, 2005 12:59:51 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, May 24, 2005

I hope everyone got to catch the ADO.NET 2.0 (What's New Overview) webcast that Mark Dunn and Glen Gordon did yesterday. If not, look for it to show up in the on-demand webcasts soon.

Tomorrow at 12pm EST I will be doing another ADO.NET 2.0 webcast with Glen, specifically on the topic of MARS (Multiple Active Result Sets). This is a great feature of SQL Server 2005 that is leveraged by ADO.NET, but before you use it, you should understand what it does, where you will benefit from it, where you will be better off without it and some potential booby traps to avoid.

MARS will let you do some really interesting stuff with transactions as well as help you write some cleaner code in your ADO.NET.

Register here for the MARS webcast.



http://www.AcehAid.org
Tuesday, May 24, 2005 8:11:24 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Sunday, May 15, 2005

I am going to be doing a webcast with DCC Glen Gordon on the topic of MARS - Multiple Active Resultsets - on May 25th. This is one of a pair of ADO.NET 2 talks that Glen and Mark Dunn are doing together, but I'll be filling in for Mark on this one. MARS is a topic that I have been digging into for almost the past year as part of my explorations of ADO.NET 2.0, so I'm looking forward to the webcast which will be full of how-to's and watch-out's!

The first webcast is an ADO.NET 2.0 overview that Mark & Glen will be doing on May 23rd.

Glen has a deep level of experience with SQL Server, so I am really looking forward to his perspective on MARS and am happy that Mark thought of me when he realized he had a difficult scheduling conflict.

You can register here for the MARS webcast.



http://www.AcehAid.org
Sunday, May 15, 2005 5:07:55 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Wednesday, May 11, 2005

SqlDependency is really easy to get working if you are an admin, but when using it in a web app (whether via the System.Data.SqlDependency or System.Web. Caching.SqlCacheDependency) it is not so easy when you are not running under an admin account, which is what you should be doing (although maybe Don Kiely and Andrew Duthie will make exceptions for Betas!) When  you deploy your apps to a web server, you will need the Network Services account to the SqlDependency work.

In addition to enabling the service broker, I had to do two additional steps when working as a non-admin.

Grant Notification Permissions to specific database
  GRANT SUBSCRIBE QUERY NOTIFICATIONS TO [MyDomain\MyGroup]

Grant NotificationErrorsQueue Perms to user (this is for all of SQL Server, so do it from Master)
GRANT RECEIVE ON dbo.[QueryNotificationErrorsQueue] TO [MyDomain\MyGroup]

But this still didn't do the trick. In Beta2 there is still a problem when SQL Server is trying to send notifications to the web server that requires opening up ports. There is a wide range of ports to open up. I tried a few but still was unable to get through. This is a known issue and will not persist through to the release mode. I will keep at it and blog the key to success when I find it.

During my presentation at the MAD Code Camp, when I got to this demo, I had to log in as admin to run it.



http://www.AcehAid.org
Wednesday, May 11, 2005 8:01:13 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Tuesday, May 10, 2005

Thanks to everyone who attended my Web Services Security and ADO.NET 2.0 sessions. I have had so much awesome feedback on the security session which I really appreciate.  The ADO.NET 2 talk is also one of my favorites. I could go on for days with that one as well.

If you are looking for the slides for the sessions and the demos from the ADO.NET talk, they are all posted on the MAD Code Camp site (that Andrew created using the ASP.NET 2.0 Clubs starter kit!!) for download as well as on my own site, on the presentations page.

Keep spreading the word that security does not have to be a mystery!!!



http://www.AcehAid.org
Tuesday, May 10, 2005 2:31:41 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Monday, May 02, 2005
One of the killer problems I originally had with SqlDependency was that I was trying to use it against an old pubs database. Finally I discovered the database property called "Database Compatibility Level" and it was set to Version80. When I changed it to Version90 the SqlDependency worked again.Well, I didn't have to do that this time and the "Database Compatibility Level" property is nowhere to be found. Well, at least *I* can't find it anymore. So that's one less thing to worry about with SqlDependency. Here is all that I had to do to get things working with the latest bits of SQL Server 2005.

http://www.AcehAid.org
Monday, May 02, 2005 7:47:25 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, April 30, 2005
I have looked at the benefits of the Load method on DataTables and DataSets that is in ADO.NET 2.0 in an article and a presentation that I have been having fun doing lately. Bill Vaughn gets really granular with the feature and proposes and interesting idea...

http://www.AcehAid.org
Saturday, April 30, 2005 8:18:19 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, April 23, 2005

Wally and I have been keen on ensuring that SqlDependency - which was pretty tricky to get working when I was first learning about it- still works. Of course it does! :-) I have a handful of SqlDependency demos in my ADO.NET 2.0 talk that worked just great with the Feb CTP bits (after a lot of figgerin' and head scratchin'). I only happen to have fired one of them up so far with Beta2.

The only change I noticed so far was that the OnChanged event is now called OnChange. (You will get a compile error message that says OnChanged is not a member of SqlClient.)

So other than that, my code that worked in Beta1 Feb CTP Bits remains the same and works charmingly.

In SQL Server 2005 the Service Broker is still not enabled out of the box on databases. So you have to remember to enable it with: ALTER DATABASE AdventureWorks SET ENABLE_BROKER

I also noticed something funny but then it went away. In SQL Server Management Studio, my tables first were listed as Contact (Person), Employee (HumanResources), etc. But then after closing it and opening it again, they went back to Person.Contact and HumanResources.Employee. I don't think I changed anything, so I'm not sure what was up with that but will keep an eye out for it.



http://www.AcehAid.org
Saturday, April 23, 2005 10:32:17 PM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Friday, April 08, 2005

I had to get a copy of one of my clients sql server db tables onto my local sql server. For some reason DTS was failing on a particular record and I couldn't identify the problem or the record or the error.

I finally gave up and went over to my whidbey box, set up an ADO.NET bulk copy and streamed the data from the remote sql server into the table on my local server.

(Without having to learn how to do a bulk copy in SQL Server)

What a great feeling!



http://www.AcehAid.org
Friday, April 08, 2005 10:17:11 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [0]  | 
 Saturday, April 02, 2005