Fix Name Pipes Provider, Error: 40

Today I have received this error on a remote server connecting from my local computer;

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and the SQL server is configured to allow remote connections. (provider: Named Pipes, Provider, error:40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2).

To fix this error goto start menu–> go to  Microsoft Sql Server –> go to configurations folder and click on sql server configuration manager. check below image.

Expand Sql Native client 11.0 Configuration manager. In client protocols you will see TCP/IP, named Pipes,Via disabled, enable those

Expand Server Network Configuration In Protocols for Sql Server here  Enable Shared,Named,TCP/IP

Expand Sql Native client 11.0 Configuration manager. In client protocols you will see TCP/IP, named Pipes,Via disabled, enable those  and restart the Sql related services. Now the error fixed.

Resources

https://www.c-sharpcorner.com/article/resolve-error-40-could-not-open-a-connection-to-sql-server/

jQuery selector change not firing

I like to fire a change event when “#btnBrowse” click event fires. Here is a sample jQuery code;

$("#btnBrowse").click(function () {
   $("#btnReset").click();
   $("#xFileUpload").click();
});

$("#xFileUpload").change(function () {
   var filename = $('#xFileUpload')[0].files[0].name;
   filename = filename.replace(/\.[^/.]+$/, "");
   //alert(filename);
   $("#xFilename").val(filename);
   fileDoc.fileName = filename;
   fileDoc.fileContnet = $("#xFileUpload").get(0).files;
 });

It turns out that click event will be registered and fired on first click only. For subsequent clicks, I have to registered a change event and triggered it like this;

$("#btnBrowse").click(function () {
   $("#btnReset").click();
   $("#xFileUpload").click().trigger("change");
});

The cons of using this approach. It will work fine for the first click but all subsequent clicks will fire a change event on click event. The reason jQuery has registered two events for the element and execute them simultaneously.

The objective is to grab file from file system. The user should be able to use same file multiple time. The best alternative to achieve this objective is to clear the contents of HTML input type rather tweaking jQuery;

This is HTML file input;

<input type="file" id="xFileUpload" name="xFileUpload" class="form-control" style="display: none" />

This is jQuery code that will clear contents of this file;

$("#btnImportReset").click(function () {
   $('#xFileUpload').val('');
});

This is your final browse script section;

$("#btnBrowse").click(function () {
   $("#btnReset").click();
   $("#xFileUpload").click();
});

Since we are clearing out HTM contents and jQuery is smart enough to figure out change. The change event will be fired this time automatically with a change in HTML file input.

Resources

https://stackoverflow.com/questions/19194177/jquery-select-change-not-firing

https://stackoverflow.com/questions/4247264/how-to-trigger-jquery-change-event-in-code

Allow users to add favorite posts in wordpress

First thing you need to do is install and activate the WP Favorite Posts plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Settings » WP Favorite Posts to configure plugin settings.

First option on the settings page is to enable ‘Add to favorite’ option for registered users only. You need to leave this unchecked if you want all visitors to see the ‘Add to favorite’ button.

Next, you need to choose where to show the ‘add to favorite’ link. The plugin can automatically show it before or after the post content. Advanced users can also choose custom method and use <?php wpfp_link() ?> template tag inside WordPress theme files.

Now you need to choose the image icon you want to show next to ‘Add to favorite’ link. The plugin comes with a few images that you can use. You can also upload your own image or don’t show any image at all.

After that you can choose the number of posts you would like to show on your favorite posts page. The default option is 20, you can change that if you want.

Lastly, you can enable or disable statistics. You will need to keep it enabled if you want to show most favorited posts in the sidebar widget.

Don’t forget to click on the ‘Update Options’ button to store your settings.

You can now visit any single post on your website and you will see the Add to Favorite link.

Showing Most Favorited Posts in WordPress

You may want to show your most favorited posts in your blog’s sidebar. Here is how you would do that.

Head over to Appearance » Widgets page. Under the list of available widgets you will notice ‘Most Favorited Posts’ widget. You will need to drag and drop this widget to a sidebar. If you need help adding widget, then check out our guide on how to add and use widgets in WordPress.

You can select the number of posts you want to show in the widget. Don’t forget to click on the save button to store your widget settings.

You can now visit your website to see the most favorited posts in your blog’s sidebar.

Showing a User’s Favorite Posts in WordPress

This plugin stores favorite posts for non-registered users in cookies. For registered users, it saves their favorite posts in your WordPress database.

Here is how you can show each user their favorite posts on your site.

Head over to Appearane » Widgets page and add ‘Users Favorite Posts’ widget to a sidebar.

Resource

https://www.wpbeginner.com/plugins/how-to-allow-users-to-add-favorite-posts-in-wordpress/

How to confirm Access Database Engine (ACE Driver) is installed on Database Server

Follow these steps to verify Access Database Engine (ACE Driver) installation;

Double check to make sure you did install the x64 version of Microsoft Access Database Engine here – http://www.microsoft.com/download/en/details.aspx?id=13255.  Please note that only one version x64 –OR– x86 can be installed, not both.

Here is a SQL Server x64 server with the Microsoft Access Database Engine x32 installed – see it does not show up.

Here is the same server with the Microsoft Access Database Engine x64 installed – see how it shows up.

I do not know of a query to get a list of the providers – however if you look in the registry at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\Providers and check for the key Microsoft.ACE.OLEDB.12.0

This will tell you that it is installed.  If you have a 32-bit version installed on a 64-bit box you would need to look under the Wow6432Node, that key would be HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\Providers.

You would have to make sure that both SQL Server and the ODBC/OLEDB driver are the same bitwise either both x64 or x32.

Possible ways to run SSIS Packages

As far as launching the package, I think we have three reasonably safe options.  The first is xp_cmdshell, which would probably work fine and be pretty simple to implement on a queue (probably the best option in my opinion). 

The second would be to create a single job agent job for each allowed broker process and have the queue processor call sp_start_job only if the job is not already running (pretty easy to check). 

The third option would be to use a CLR procedure to call a web service and have the web service start the SSIS package.  You would have to dive into C# a bit and create your own web service to start an SSIS package, but it is not much code.  Doing it this way, you would not have to allow unsafe assemblies because the web service would be out of process.

Keep in mind that starting a job is asynchronous, and would require additional coding in both the job and the application that starts the processes, as well as creating a job for every SSIS package that needs to be run.  Using xp_cmdshell is synchronous, and requires that xp_cmdshell access be enabled (requires security configuration).  It does require the writing of a command line for each package, but that can also be stored in a table and pulled when needed.

BOL shows code for running SSIS packages in an application.  I am hoping, though not encouraged, that it may be possible to use a CLR stored procedure to run a SSIS package inside the database by simply passing the name of the package to run.  We won’t need 100’s of jobs, or enable xp_cmdshell to accomplish the task.  I am, however, pragmatic and will use which ever method turns out to be the best/easiest/quickest/etc way to meet the goals of the system: to reliably import the data from numerous source systems in the most efficient way possible and to recover from hardware/network failures/outages both planned and unplanned.

Here is another option;

https://www.mssqltips.com/sqlservertip/2992/how-to-execute-an-integration-services-ssis-package-from-a-sql-server-stored-procedure/