SQL Server Protocol error in TDS stream Communication link failure TCP Provider: An existing connection was forcibly closed by the remote host

by Cliff 28. September 2009

Recently ran into an issue with long running sql queries that used TCP to communicate between different SQL Server servers.  We sporatically noticed the below errors and SQL job failures for jobs that ran long running sql queries.

Error: 2009-09-28 08:43:40.62     Code: 0xC0202009     Source:      Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Protocol error in TDS stream".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "TCP Provider: An existing connection was forcibly closed by the remote host.  ".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is ...  The package execution fa...  The step failed.

After some research, the below KB article outlines that TCP Chimney may be the cause.  Turns out, TCP Chimney may require an update the your NIC drivers.  

http://support.microsoft.com/kb/945977

We have not had the chance to upgrade our drivers, but we did disable TCP Chimney and that eliminated the error. To disable, issue the below statement at the command prompt (does not require a restart):

Netsh int ip set chimney DISABLED

.NET how to set the background color of a bitmap

by Cliff 3. September 2009

I was struggling with this for a while...how to set the background of a bitmap.  I read a few suggestions, but none worked for me. 

My need was to set the background of the image to white, crop it, with the end result that after cropping, the background be set to white.

To do this, I used the Clear method on the Graphics class...essentially this sets the background.

 

Graphics grPhoto = Graphics.FromImage(bmpImage);

grPhoto.Clear(Color.White);

grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
                new Rectangle(destX, destY, destWidth, destHeight),
                new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                GraphicsUnit.Pixel);

            grPhoto.Dispose();

System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to

by Cliff 2. September 2009

We were gettign an error with one of our WCF services "System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to..." and needed to get additional information on the problem.  Below are steps to use the built in diagnostics with WCF to find out more info for the error above as well as the overall health of your service.

  1. Add to your web.config:

     <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
              <add name="messages"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="D:\LogFiles\SalesOrderTrackingService\messages.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

    <system.serviceModel>
        <diagnostics>
          <messageLogging
               logEntireMessage="true"
               logMalformedMessages="false"
               logMessagesAtServiceLevel="true"
               logMessagesAtTransportLevel="false"
               maxMessagesToLog="3000"
               maxSizeOfMessageToLog="2000"/>
        </diagnostics>
    ...
  2. Create the necessary folder and ensure the security is set so IIS/ASP.NET can write to the log file
  3. Use the SvcTraceViewer.exe application to view your log file

    This tool can be found in the SDK directory...for me, this was C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin

.Net | WCF

System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request

by Cliff 27. August 2009

Recently I had a WCF service call that was returning the error System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (400) Bad Request.

Looking into this, I discivered that the messages we were sending were increasing in size.  We were using the basic http binding and it turns out the default readerQuotas were too small and were causing the"Bad Request" error.

I increased the readerQuotas to the values below and that resolved the error.

 

<basicHttpBinding>
        ...
          <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000"
            maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />

       ...

Tags: wcf

.Net | WCF

SQL Server Full-Text search remove noise words

by Cliff 23. August 2009

SQL Server full-text search filters out certain noise words by default.  If you want to include some of these noise words in your full text search, you will need to do the following.

  1. Locate the noise file for your language.  For English, this would be noiseENU.txt and is located in the SQL Server install directory.  For example C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\FTData (Your location may vary).  You can also use the following query to help determine the location:

    select * from sys.fulltext_catalogs

  2. Edit this file.  You can add or remove noise words/numbers, etc. from this file.

  3. The last thing you must do is rebuild the catalog (*Note, if you have a large catalog, do this off-hours as it will impact performance):

    ALTER FULLTEXT CATALOG YourCatalogNameHere
    REBUILD WITH ACCENT_SENSITIVITY = OFF
Now, the next time you run a full-text search, your changes will be factored in.

No Software

by Cliff 21. August 2009

I continue to see a trend with most businesses to move away from the self hosted, home grown, monolithic applications and move more to service based software.  While there are some big and well know players, such as Salesforce.com, there are many smaller up and comers offering a wide array of software services that do not require any on site software or custom development.

One compnay in particular, Feed.Us offers a wonderful online content management system (CMS) that in addition to traditional content management, offers many value added services.  The real joy of this system is you can get up and running in minutes.  You can transform your static web site into a dynamic web application with little to no custom development.

I really recommend you check out all of the features they offer...

 

 

jQuery UI modal dialog focus issue

by Cliff 1. August 2009

I noticed while using the jQuery UI modal dialog that if you have a link (or form element) within your HTML in the modal, the focus will be given to the first one.  If the element is further down on the modal, then it will scroll down, which is not the desired behavior.

To correct this, I simply added a link at the top of the modal and gave it focus:

 Place at top of modal HTML:

<a id="top" href="#" ></a>

In document ready, add focus to #top:

jQuery(document).ready(function() {

            // Tell jQuery that our div is to be a dialog
            jQuery("#dialogTOS").dialog({ autoOpen: false, height: 400, width: 900 });

            jQuery('#linkTOS').click(function() {
                jQuery('#dialogTOS').dialog('open'); 

               // Focus on top element
                jQuery('#top').focus();
            });

        });

LINQ Sequence contains more than one element

by Cliff 24. July 2009

Recently I ran into an issue with the contains method in LINQ in conjunction with the SingleOrDefault method.

My query was similar to:

var data = (from i in ctx.DataContext.orders
where order.Contains(i.Name)
select i).SingleOrDefault();

and this was throwing the error:

System.InvalidOperationException: Sequence contains more than one element

Turns out the Contains translated to a LIKE '%...%' and was returning multiple records.  By changing this to i.Name == order, then I got back the single result I was expecting.

jQuery with ASP.NET selected index changed

by Cliff 18. July 2009

Recently I had the need to handle the selected index changed event in an ASP.NET page.  I did not want to post back to the server as I just wanted to hide/show an HTML element, so jQuery was the perfect fit.

Below is the code.  Basically, within the jQuery document ready funciton, I wire a function to each dropdown list ('select') change event.  You will probably want to refine this to a single id or class.  Each time the dropdown selected index changes, I want to check the text value, and if it contains some text, either show or hide an HTML element.  I also set a checkbox control to checked using the client id within a script tag.

<script type="text/javascript">

$(function() {

$('select').change(function(e) {

if (this[this.selectedIndex].text.indexOf("SomeText") > 0) { $('#emailActivity').fadeIn("slow");

// Ensure checkbox initially checked

$('#<%=cbSendEmail.ClientID %>').attr('checked', true);

}

else {$('#emailActivity').fadeOut();

}

});

});

</script>

Delete not working with LinqDataSource

by Cliff 30. June 2009

Recently I was working on a custom page in a Dynamic Data project and the "Delete" link was not working on a GridView that had a LinqDataSource as its data source.  Below are the steps I followed to resolve:

First, I was getting an error when clicking delete for a record in the GridView

LinqDataSource 'GridDataSource' does not support the Delete operation unless EnableDelete is true.' when calling method

This was fixed easily by setting EnableDelete="true" on the LinqDataSource.

Next up, I needed to set the DataKeyNames on the GridView.  This basically indicates what the where condition will be for the delete operation.  I set the GridView DataKeyNames equal to the name of the primary key column in my table.

That will probabaly resolve for most people, but for me, it did not.  I had also set the Select property on the LinqDataSource and this was preventing the delete from occuring.  Once I REMOVED the value for this propery, all worked.

The below article was helpful in diagnosing:

http://msdn.microsoft.com/en-us/library/bb514963.aspx

 

Cliff Gray's Info

Cliff Gray
Developer/Founder GrayTechnology.com.

E-mail me Send mail

Authors

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

Blogroll

Download BlogEngine.NET

Download at CodePlex

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Subscribe