Monday, May 8, 2017

DataReader In ADO.net

Introduction:


In this article I will explain you about datareader in ADO.net using C#.net

DataReader


DataReader is used to read the data from database and it is a read and forward only connection oriented architecture during fetch the data from database. DataReader will fetch the data very fast when compared with dataset. Generally we will use ExecuteReader object to bind data to datareader.


protected void BindGridview()

{
------some code----
SqlDataReader dr = cmd.ExecuteReader();

-----some code to be write here-----

}

Friday, May 5, 2017

Import CSV File into Database Table Using SSIS

How to Import CSV File into Database Table Using SSIS?

Hello all today i have share my knowledge with you how to import Data into sql server using SSIS package from .csv file.

Create the table where we want to insert the CSV file.
Where i will import my CSV.
1
2
3
4
5
6

CREATE TABLE [dbo].[CSVFile](
       [col1] [varchar](50) NULL,
       [col2] [varchar](50) NULL,
       [col3] [varchar](50) NULL
) ON [PRIMARY]

GO

Note:-I have try with very small data you people can change according to your requirement.


Open SQL Server Business Intelligence studio.Create a new project and save it.(I am using SSDT tools 2010)

Click on Control Flow and drag Data Flow Task to the right side pan.

 Double click on the Control Flow task.


In Execute SQL Task I am delete data from table.


It will take you to Data Flow pan.

Drag Flat File Source from Toolbox to Data Flow task pan.

Configure New Connection by clicking New.


Select the Path of the file and specify Text Qualifier. For me the text qualifier is comma (“) Where we have Col2 has value 23,000 which may consider Col2 = 23 and Col3 = 000.
Trick is to wrap value by double quote - "23,000" and use Text Qualifier = “(In Flat File Connection manager)

Click on Columns and adjust Output Column Width – match it with width of your original data. If you do not know leave it as default (at 50).

Click on following screen.


Now Select OLE DB Destination from right side Toolbox and drag to below the Flat File Source.

Put them near to each other demonstrated below.

 Connect Green Arrow of Flat File Source with OLE DB Destination.

 Double click on OLE DB Destination and connect to the database and table created earlier in the code.
 After configuring connection the mapping needs to be adjusted as well.
 Now on mappings tab connect both the size. I have not connected very first column as it is identify column for me.


 Clicking OK will bring me to following screen.
Now click on F5 and it will execute the package in debug mode.
 The below is my final output.


THANK YOU SEE YOU AGAIN (:




Friday, April 14, 2017

Could not load file or assembly 'System.Data.SQLite' or one of its dependencies...

If you facing the issue "

"Could not load file or assembly 'System.Data.SQLite' or one of its dependencies..." 



one of Causes:

Enable 32-bit applications is set to True.

Solution:

  1. Go to the Advanced Settings:
  2. Set Enable 32-bit Applications to False.
  3. Click OK.


 I think it will help  you thank you happy coding. 

Wednesday, April 12, 2017

Today first time i am using the  Package Manager Console, for run Install-Package MSBuildTasks,
when i am running the command "Install-Package elmah" i am facing the below issue


PM> Install-Package elmah
Install-Package : The current environment doesn't have a solution open.
At line:1 char:1
+ Install-Package elmah
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetNoActiveSolution,NuGet.PowerShell.Commands.InstallPackageCommand



So i have think put this post might be help to some one.


The solution are as  below :-



I usually get this error because I created or opened a project (.csproj or other) that doesn't have a saved solution (.sln) associated with it.
If you go to File->Save All it should offer to save the solution somewhere. Save it and that makes the error go away for me.

Thank you,
Arjun Walmiki 

Thursday, March 16, 2017

How to find Nth highest and lowest salary in SQL?

This is the one of the most common question asked in SQL.

 "How to find Nth highest or lowest salary in SQL"

If you find the answer using the "TOP" keyword 
Than  interviewer ask you can you find out with other way 

so i will tell to some step including the top

But before start we need one employee table it is as below 







1. To get max salary from Employee table.


SELECT MAX(salary) FROM employee;

2. To get salary using Top.

SELECT TOP 1 Salary AS 'Higest Salary',Name FROM (SELECT DISTINCT TOP 3 Salary,Name FROM tblSalary ORDER BY Salary DESC) a ORDER BY Salary ASC 


Instatllation process of MSMQ properly in the computer(OS Window Server 2012 r2) using GUI

Microsoft Messaging Queue (MSMQ) technology is used for asynchronous communication using messages. MSMQ also can be considered to be an Inter- process communication capability.

Step 1: Need to ensure MSMQ is properly installed in the computer.


1. How to check?
  • Type "compmgmt.msc" in the Run window or right-click on MyComputer and select "Manage Computer".
  • The following screen shot shows the MSMQ installed in the computer, if its not listed then follow Step "c" else done.



Go to the Control Panel and select "Add or remove programs" under "Programs and Features"
  • After clicking on "Add or remove programs" again click "Turn Windows features on or off" displayed on left side select "Local Sever" from Server Manager.
  • When you click on "Local Sever" new window will be open "Add Roles and Features Wizard" Click Next.when you Got "Features" Option on left side.
  • Check (as in the following screenshot) whether MSMQ is enabled or not; if not then select "Enable" and press "OK"; see:




2. Once MSMQ is installed expand the MSMQ feature; there will be the following queues:
  • Private queues are queues that are not published in the Active Directory Domain Services and are displayed only on the local computer that contains them.
     
  • Public queues: In a domain environment, public queues are queues that are published in Active Directory Domain Services and hence are replicated throughout your Windows Server . 

Tuesday, December 6, 2016

Java Language Conversion Assistant (JLCA)

The Java Language Conversion Assistant (JLCA) is a tool that automatically converts existing Java-language code into C#. This tool accepts Java files and converts them to equivalent C# files. It creates its own project for doing so. Also TODO’s are inserted into your C# code wherein the JLCA converter fails to find the equivalent C# code. Version 2.0 of this tool ships with Visual Studio .NET 2003 and can be installed during Setup. This tool is also available with VS 2005. Now it becomes very easy for the developers to migrate their existing Java application to Microsoft .NET framework.
More information on this tool can be obtained from: www.microsoft.com/en-us/download/details.aspx?id=14349



Thank you,
Arjun Walmiki