18.12.12

Sending Email through ASP.Net or Dotnet applications

Here is the small piece of code to send emails through Dotnet Applications

   MailMessage mail = new MailMessage();
  mail.To.Add(To Addressd");
 
  mail.From = new MailAddress("GmailID@gmail.com");
  mail.Subject = "Subject of your email";

  string Body = "Hi, this mail is to test sending mail"
         
  mail.Body = Body;
  SmtpClient smtp = new SmtpClient();
  smtp.Host = "smtp.gmail.com";
  smtp.Port = 587;
  smtp.UseDefaultCredentials = False;
  mail.IsBodyHtml = true;

  
  smtp.Credentials = new System.Net.NetworkCredential
       ("GmailID@gmail.com","Ur Gmail or email password");

  smtp.EnableSsl = true;
  smtp.Send(mail);

 Sometimes, you may face the below error while sending the email from your app.
"The remote name could not be resolved: 'smtp.gmail.com'"

Fix for this issue: "The remote name could not be resolved: 'smtp.gmail.com'"

  1. Check ur Internet connection - This could be the main problem
  2. Ur email is blocked for some reason.
  3. Ur domain administrator or ur domain is blocked.

Cheers,
Venkatesan Prabu .J
http://www.facebook.com/KaaShivInfoTech

23.11.12

Problem with Outlook - Can't Select text in the content area

Recently, I've faced an issue with Microsoft Outlook and started searching for the solution. For god's sake, I got a very good solution from the below URL.

It may be useful for my blog readers too.

 http://social.technet.microsoft.com/Forums/en/office2010/thread/4c8780f5-bbb9-449d-a1fb-2ab668fcceb3

1.            Exit Outlook.
2.            Go to Start > Control Panel, click or double-click Mail.

Mail appears in different Control Panel locations depending upon the version of the Microsoft Windows operating system, Control Panel view selected, and whether a 32- or 64-bit operating system or version of Outlook is installed.

The easiest way to locate Mail is to open Control Panel in Windows, and then in the Search box at the top of window, type Mail. In Control Panel for Windows XP, type Mail in the Address box.

 Note    The Mail icon appears after Outlook starts for the first time.



The title bar of the Mail Setup dialog box contains the name of the current profile. To select a different existing profile, click Show Profiles, select the profile name, and then click Properties.

3.            Click Show Profiles. Choose Prompt for a profile to be used.
4.            Click Add.
5.            Type a name for the profile, and then click OK.
6.            Start Outlook, and choose this new profile. Create a new message and send to yourself in this profile.

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
http://www.facebook.com/KaaShivInfoTech

function is not a recognized built-in function name - Error - Fix


Usually, functions are created to incorporate re-usability features. 

In the below query, we are trying to create a function which will return a string and this comes under "User defined function returning scalar values or scalar user defined function"

create function VenkatFunction()
returns varchar(100)
as 
begin 

  return 'VenkatSample'
  end 

With encryption is an option to restrict other to view or modify the user defined functions.


create function VenkatFunction()
returns varchar(100)
with encryption
as 
begin 

  return 'VenkatSample'
  end 
  
To access the function, you can use 
  select   VenkatFunction()

Oops, it will thrown an error indicating "function is not a recognized built-in function name "

Solution:  you need to use schema name in the front of the function to overcome this error.

You need to use  select dbo.VenkatFunction()

Cheers,
Venkatesan Prabu .J
http://kaashivinfotech.com/
http://www.facebook.com/KaaShivInfoTech

24.8.12

The OFFSET-FETCH Filter in select clause


This is one of the fantastic feature introduced in SQL Server.

As we all know about "Top" Clause. It will filter the data in a specific order.

              Select Top (10) * from Venkat_Table

The above query will fetch top 10 records from the table.

We don't have any provision to avoid a set of data and fetch the next level of data. Here is the provision and it can be done using Offset-Fetch Filter option.

Here is the query format,

create table venkat_Table( id int identity(1,1), val varchar(100))
go
insert into venkat_Table values
('a')
go 25
go
insert into venkat_Table values
('b')
go 25
select * from venkat_Table
GO
select * from venkat_Table
offset 25 rows fetch next 10 rows only


The above query will fetch 10 rows after leaving 25 rows.

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech

Select Query order in SQL Server


Writing my articles after a very long break. Tied up with lot of activities with my company KaaShiv InfoTech. Met lot of people, new environment, New friends, New Technological ideas.... lots of new things happening around me.

I feel like, I've missed out something even I was tied up with lot of activities that's nothing but my technological updates. I've decided to start my articles in this blog Hope it will go a long way from now. Let's see. 

As we are familiar with "Select" clause. Here is the logical order the query will be processed in the Select clause


1. FROM
2. WHERE
3. GROUP BY
4. HAVING
5. SELECT
6. ORDER BY

Example Query:

FROM Venkat_EmployeeTable
WHERE custid = 1071
GROUP BY empName, YEAR(orderdate)
HAVING COUNT(*) > 10
SELECT empiName YEAR(orderdate) AS orderyear, COUNT(*) AS numorders
ORDER BY empid, orderyear

Cheers,
Venkatesan Prabu .J

10.8.12

Chief Guest in VRS Engineering College



                 Venkat as a chief guest in VRS college of Engg & Tech



                            Venkat deliver the speech

9.8.12

Chief Guest in Sasurie Engineering College

 

                 Venkat as a chief guest in sasurie college of engg

 

                        Venkat lighting the kuthu vilakku


                           Venkat deliver the speech

Chief guest in CSI Engineering College

 

             Venkat as a chief guest in CSI engineering college



                 Venkat deliver the speech


Chief guest in Saveetha Engineering College




                                       Venkat as a chief guest in Saveetha Engineering college



                                 
                                                Venkat deliver the speech to audience

3.7.12

How to get and install an OpenGL wrapper for .NET


 Reference : http://edndoc.esri.com/arcobjects/9.2/NET/0b0cb380-490e-4c8e-829d-d8083967387b.htm

Download and include CsGL-OpenGL.NET library

  1. In your Web browser, navigate to the download site of the CsGL-OpenGL.NET library. The download site's URL is:
    http://sourceforge.net/project/showfiles.php?group_id=33241&package_id=38395.
  2. Download csgl.1.4.1.dll.zip to your local drive and unzip it. See the following screen shot:





Add a reference to the CsGL-OpenGL.NET library in your solution. See the following screen shot:






















 Add a using directive in your code. See the following:
 
[C#]
using CsGL.OpenGL;



Here is the latest version of installation from my knowledge,


Unzip the installable and goto libinstall and click the batch file.



Register the dll file in gac


 Cheers,
Venkatesan Prabu. J






25.5.12

Option to access the Column Names in Data table


Here is the option to access the column (header) name of a datatable.

DataSet ds = new DataSet();
ds.Tables[0].Columns[0].ColumnName

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx

Open multiple windows in browser startup. (Multiple homepages option)

If you want to open two sites simultaneously, there is an option available in IE. Just go to Options page of your IE browser and provide multiple URL’s. Click “Apply” and “Ok”. Close the browser and start the browser once again. Eureka, hope you are able to see two tabs opening simultaneously.





Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx

20.5.12

Upgrading the version from Evaluation to Standard/Enterprise/Developer version

For the people who are using evaluation version of Microsoft SQL Server, you will face the below problem after a certain period. While trying to access SSMS. You will get this error.
Evaluation period has expired. For information on how to upgrade your evaluation software please go to http://www.microsoft.com/sql/howtobuy (http://www.microsoft.com/sql/howtobuy)

There are two ways to fix the above error message:
1. Install Service Pack 1 before upgrading SQL Server 2008 evaluation edition to any licensed edition.
2. Modify Registry. Go to Start->Run->Regedit. In the Registry Editor, select the following keyHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\100\ConfigurationState and change the value of the Common Files REG_DWORD to 3 as shown in the figure below.
http://msdn.microsoft.com/en-us/library/ms143393.aspx




After completing the registry changes, run the edition upgrade and you are done. For a list of supported version and Edition upgrades, check out the following:




You need to provide appropriate keys and install the software or upgrade the software successfully.

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx

15.5.12

Query to Create comma separated Output.





Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx

How can we force SQL Server to use a specific index when executing a query?





Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx

Query in one of the forum:



using Below sample query(2 times same query with one condition as extra) to get the 2 type of result set.

IF @Status = 'A'
Select * From TableName where ID = @ID and Value > 200
Else
Select * From TableName where ID = @ID

How can i use Case statement to avoid to create the same select statement 2 times.


Here is my answer to achieve the same.





Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 


REBUILDING VS REORGANIZE THE INDEX


When an index is rebuilt, it is dropped and a new one is created.
In the process fragmentation is removed and disk space is reclaimed.

ALTER INDEX PK_CustId ON Sales.Customer REBUILD

REORGANIZE THE INDEX
Minor Level modification, so that rearranging of the tree node is done.
 Small Fragmentation is removed, the index remains.

ALTER INDEX PK_CustId ON Sales.Customer REORGANIZE

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 

Variable in Top Clause (Dynamic value for the top clause):


Suppose, If we want to pass the arguments for getting top number of records we can achieve it by declaring the variable and using the variable as below.




Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 


Get the Top Data with Ties from SQL Server (If there are same data….Ties in data will happen. If we need all the data.)


In this scenario you need to use With Ties option





In the second query, I’ve given Top 3 data. But the third and fourth data is having a tie up which inturn enables the query engine to fetch both the data which are in Ties.

·         WITH TIES OPTION MAY CAUSE MORE THAN THE SPECIFIED NUMBER OF RECORDS TO BE DISPLAYED

·         BECAUSE IT DISPLAYS ALL OF THE RECORDS MATCHING THE LAST RECORD'S ORDER BY CLAUSE

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 










Get the Top Data from SQL Server



Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 


How to use dynamic sql for a nvarchar of more than 4000 characters?


Usually, it's a typical problem we will face while executing the Dynamic SQL the length of the string is really huge when compared to the max length of the string. To overcome this major issue. Here is a small alternative. We can have part of the execution string in one variable and remaining part in the other string.
  A small example

find columns having index?
 sp_helpindex  tblUserDetails


sp_help tblUserDetails





EXEC sp_msforeachtable @command1= "PRINT '?'  
EXEC sp_helpindex @objname = '?'"


Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 

SET or SELECT -- is there any performance difference?


It doesn't have major performance difference between the Set and Select statement. The only thing is the usability nature of the commands.

            SET @variable = (SELECT datacolumn FROM tablename)
The above statement should return a single value which will be assigned to the variable. Here, if the results of the subquery expression is empty then @variable has a value of NULL but if the results of the subquery are more than one row then you get a error.
And thus it makes sense while,

SELECT @variable = columnvalue FROM dbo.tablename

returns a value from a number of rows and we are not sure what’s the criteria in selecting that row.

 One major difference in assigning using SET and SELECT is:

SET @variable1 = 'somevalue', @variable2 = 'someothervalue'

This is NOT possible but the same is possible with SELECT as in:

SELECT @variable1 = 'somevalue', @variable2 = 'someothervalue' 

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 

Difference between Stored Procedure (SP) and User Defined Function


Ø   User Defined Function can be executed using the “SELECT” clause whereas Stored Procedure cannot be Executed..
Ø    User Defined Function does not return any output parameters while Stored Procedure will return output parameters.
Ø   User Defined Function cannot make permanent changes to server environments while SP’s can change some of the server environment.
Ø   If there is an error in UDF its stops executing. But in SP’s it just ignores the error and moves to the next statement.

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx 

14.5.12

Chief Guest for Jaya Engineering College, Faculty Development program



Chief Guest for Jaya Engineering College, Faculty Development program on Microsoft Technologies

Program Coverage : 

      Session 1:  Talk on Latest  Microsoft Technologies (WCF, WPF, Cloud Computing, Dotnet Framework, Denali, Web Matrix, Windows Server 2008)

      Session 2:  Talk on basic C# and Dotnet Framework Concepts.



My talk about Cloud Computing (SQL Azure and WinAzure):


Talk about Denali and it's new Features:





It was a fantastic session and I really enjoyed the arrangements and facilities provided for this program. Had a great lunch :-) and came back to my office.

Thanks to Anna University and Jaya Engineering College for arranging this session.

Cheers,
Venkatesan Prabu .J
Head, KaaShiv InfoTech
For free Ebook : http://kaashivinfotech.com/Ebooks.aspx