Saturday, December 2, 2017

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.(System.Data)

This happens only for Office 2007 or higher as it requires use of OLEDB ACE drivers for connection which do not come by default in Windows and hence we need to install them in order to get rid of this error.

You can solve this issue , by installing the drivers. for more information, you can visit the links below:

Error 1061 : service cannot accept control messages at this time

This error occurred when we try to stop /reboot the service.

There is a temporary mismatch between the requested control and the state of the service to be controlled. The service may be in a state of start-pending, stop-pending, or stopped.

There are two ways to stop the service.
1. Go to task Manager and kill the process and try now, it will work
2. Disable the startup type and restart the server. this will disable the service.

Wednesday, November 29, 2017

What is the difference between smalldatetime and datetime?



DateTime SmallDateTime
Storage Size 8 Bytes 4 Bytes
FORMAT YYYY-MM-DD hh:mm:ss.nnn YYYY-MM-DD hh:mm:ss
MIN Value 1753-01-01 00:00:00 1900-01-01 00:00:00
MAX Value 9999-12-31 23:59:59.997 2079-06-06 23:59:00
Accuracy Rounded to increments of .000, .003, or .007 second
It means:
If time part in the date is 23:59:58.990 or 23:59:58.991, it will be stored as 23:59:58.990.
1 Minute
Second’s values that are 29.998 seconds or less are rounded down to the nearest minute. And second’s values of 29.999 seconds or more are rounded up to the nearest minute. So seconds part value is always 00.

Tuesday, November 28, 2017

C#, create folder dynamically or check folder exists

string subPath ="ImagesPath"; // your code goes here
bool IsExists = System.IO.Directory.Exists(Server.MapPath(subPath));
if(!IsExi System.IO.Directory.CreateDirectory sts)
System.IO.Directory.CreateDirectory(Server.MapPath(subPath));

Monday, November 6, 2017

Steps to Create twitter application


Steps to Create twitter application:

To use Twitter counter widget and other Twitter related widgets, you need OAuth access keys. To get Twitter Access keys, you need to create Twitter Application which is mandatory to access Twitter.
  1. Go to https://dev.twitter.com/apps/new and log in, if necessary
  2. Enter your Application Name, Description and your website address. You can leave the callback URL empty.
  3. Accept the TOS, and solve the CAPTCHA.
  4. Submit the form by clicking the Create your Twitter Application
  5. Copy the consumer key (API key) and consumer secret from the screen into your application

SQL Server, Connection String creation

Whenever we need to create a connection string for a new database or in the same database then we need to follow simple few steps listed below:
  1. Create the login in the master database using the query given in the above mentioned reference file name or see as given
    CREATE LOGIN [XYZ] WITH PASSWORD=N'XYZ',
    DEFAULT_DATABASE=[Master], DEFAULT_LANGUAGE=[us_english],
    CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
    GO

    NOTE-if you are using the sql server GUI to create a new login then please make sure to un check the enforce password policy otherwise there would be problem with the connection string in the near future
  2. Create the User in the concerned Database and attach the user with the particular login any failure in doing so will result an error while using the connection string. Set the default schema name with it too (default schema name is useful as all the procedures under that default schema can be accessed by the application using the procedure name only if any other schema procedure need to be executed which has the permission then application need to specify the schema name along with the procedure name otherwise the procedure will not be found.
    CREATE USER [XYZ] FOR LOGIN [XYZ] WITH DEFAULT_SCHEMA=[schimabnameSP]
    GO
  3. Create the Role using the query given in the above mentioned file. The role plays the most important part in the assignment of the permission to different schemas or database objects for the newly created login or connection string.
    CREATE ROLE [DBR_rolename] AUTHORIZATION [dbo]
    GO
  4. Go to the concerned database security folder and then into the schema folder select the particular schema for which we need to assign the permission.
  5. Click the property after the right click on the schema
  6. In the property go to the permission tab and search for the "Role Name" and give the execute permission and then save it and close the pop up
  7. Then go to the "User" folder and right click on the concerned user and select the role from the list shown below and close the pop up after clicking "OK" button.
If all the steps are followed then the connection string will work properly
Common Loop Hole –
  1. In order to check the connection string when we login with the user name and password set in step 1 then we are unable to see the procedure list (solution user is not associated with the role)
  2. "Execute permission is denied" this is the common issue reported by the application developers (Solution check if the application developer is using correct connection string or not and if the connection string is right then we need to check if the concerned schema is associated with the correct role with the execution permission) (Solution if the above solution is not solving the problem then check if the User is associated with the schema or not if so then remove the user and use role )
NOTE- We do not give any permission to the schema under which we make tables and views, only schemas which has the procedure need to be given EXECUTE PERMISSION. Schema should not have the direct permission for the user in any circumstances.
Need to give access to different database in the same server
Go to the login name right click on it and go to the “User Mapping” tab and select the concerned database. on selection of the database all the roles for that database will be listed below select the desired role and save the setting.

Sunday, November 5, 2017

A href open in new tab, same frame, parent frame and reuse the existing One

Open the linked document in a new window or tab:
 <a href="xyz.html" target="_blank"> Link </a>
Open the linked document in the same frame as it was clicked (this is default):
 <a href="xyz.html" target="_self"> Link </a>
Open the linked document in the parent frame:
 <a href="xyz.html" target="_parent"> Link </a>
Open the linked document in the full body of the window:
 <a href="xyz.html" target="_top"> Link </a>
Open the linked document in new tab and Reuse the existing one if already open:
 <a href="xyz.html" target="framename"> Link </a>

Install WordPress on local machine


To use WordPress you must have a server (WAMP, XAMP) installed on your machine for its working environment. Without a server you won’t be able to install WordPress.

  1. Download/Install WAMP Server: WordPress needs a web server (which could be anyone, for e.g. I have used WAMP software for installing WordPress) to work on so first you need to download and install a software called WAMP (which has prebuilt localhost server) on your machine.
  2. Activating WAMP Server: Remember, every time you turn on your machine, first you will need to activate WAMP server simply by double clicking on its icon.
  3. Download WordPress Zip:Open your browser. Go to www.wordpress.org/download/ and easily download the latest version of WordPress.
  4. Deploy the code at Wamp Directory: Open your directory where you have installed WAMP server & copy the zip folder of WordPress here and do right click on it and select “extract here”.
    Now make a copy of the folder and rename it, here for e.g., it is renamed as “WebsiteName”
  5. Create Database: Open your web browser window and type the following on your address bar “localhost/phpmyadmin/” and press enter.

    Now, select the database and create a database for your WordPress, lets say for e.g. “table” as shown in the figure below.

    Simply click on create and your database is ready to use.
  6. Install WordPress file: Now type “localhost” on your browser. From there, select your copied folder (the one which you renamed for your WordPress website).

    After this, following page will be obtained as shown in the figure below.
    Now, click on the button ”Create a Configuration file” on the same page.

    Now, after performing the above step, on the next page click on “Let’s go” button.


    Now, this step is very important. You need to be little careful here. Keep in mind few things and proceed in this way:-
    • Database Name should be same as that what you have created earlier for your WordPress.
    • Username is “root” by default as per MySQL user name.
    • The password should be left blank if you haven’t mentioned it at the time of creating your database otherwise type the same one if you have mentioned it earlier


    After this simply fill the respective fields on the next page and at last click on the button ”Install WordPress”. Your page will look like as shown in the figure below:


  7. you have successfully installed WordPress on your machine.
    Just to make sure that you have done all the steps in a perfect manner, you can login to your account.

Monday, October 2, 2017

Create a copy of database and renaming it using mdf & ldf files

If You want to use the same directory for your mdf\ldf files You will have to (physically) rename them.
1. Detach files from local PC
2. Rename mdf and ldf files
3. Copy\Move the files to the server directory where the original Database is stored.
(In My example I used D:\Data for mdf and E:\Logs for ldf, change the path before running the script)
4. Use this code:

USE [master]
GO
CREATE DATABASE [myNewSite_db] ON 
( FILENAME = N'D:\Data\myNewSite_db.mdf' ),
( FILENAME = N'E:\Logs\myNewSite_db_log.ldf' )
FOR ATTACH
GO

Sunday, October 1, 2017

Difference Between String and StringBuilder


String are Immutable (Not Modifiable). If you try to modify the string it actually creates a new string and the old string will be then ready for garbage collection.StringBuilder when instantiated, creates a new string with predefined capacity and upto that capacity it can accodomate string without needing to create a new memory location for the string....i mean it is modifiable and can also grow as and when needed.

When the string needs to be modified frequently, preferably use StringBuilder as its optimized for such situations.