Thursday, March 1, 2007

Stored Procedure-Importing CSV Files into Table -SQL Server

Here is the Stored Procedure code for importing comma seperated CSV files to table.


CREATE PROCEDURE [dbo].[sp_ImportScript]
@filepath varchar(2000)
AS
BEGIN TRY
declare @tmpsql varchar(3000)
set @tmpsql='BULK INSERT table'
set @tmpsql=@tmpsql + ' FROM ''' + @filepath + ''''
set @tmpsql=@tmpsql + ' WITH (FIRSTROW=2,FIELDTERMINATOR ='
set @tmpsql=@tmpsql + ''','''
set @tmpsql=@tmpsql + ',ROWTERMINATOR ='
set @tmpsql=@tmpsql + ''','''
set @tmpsql=@tmpsql + ')'
EXEC(@tmpsql)
select @@rowcount
END TRY
BEGIN CATCH
DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
SELECT @ErrMsg = ERROR_MESSAGE(),
@ErrSeverity = ERROR_SEVERITY()
RAISERROR(@ErrMsg, @ErrSeverity, 1)
END CATCH
Share:

How to set default value of a property in Class-C# 2.0

If you wanna set properties default value at the time of Class Instance creationg here is code that.

Import following name space to your class with using directives.

using System.Collections.Generic;
using System.Text;
using System.ComponentModel;

Then create a private variable field for property

private string _message;

Finally here is code that generate default value with property.

[DefaultValue("This is default value of message")] //this code generates default value
public string Message
{
    get
    {
        return _message;
    }
set
    {
        _message = value;
    }
}



Note: You can create a DefaultValueAttribute with any value. A member's default value is typically its initial value. A visual designer can use the default value to reset the member's value. Code generators can use the default values also to determine whether code should be generated for the member.

For more reference see following link - http://msdn.microsoft.com/en-us/library/system.componentmodel.defaultvalueattribute.aspx
Share:

Meta Tag Extractor

For Search engine optimization Meta Tag is very much important to rank your site within the search engine.

A SEO person always require meta tag extractor to get meta tags from vairous sites and find best keywords that match your site.

I have found a great meta tag extractor here is a link :
http://www.iwebtool.com/metatags_extractor
Share:

Microsoft India Blogstar Content Winners

Microsoft India has conducted Microsoft India Blogstar Contest to encourage Microsoft technology related blogger.

The winners have a chance to meet Steve Balmer -CEO Microsoft Corporation.The winners are announced.

Here is the link:
http://www.microsoft.com/india/blogstars/winners.aspx
Share:

Filling typed dataset with enterprise libary 2006-C#

Here is the code filling data with enterprise library.

First Create a Type dataset in the visual studio dataset called 'crystal'.
Then create a data table via right click add datatable called script.create
columns you require.

and then first import following name space using directives.

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary;
using System.Data;
using System.Data.Common;

Database db = DatabaseFactory.CreateDatabase("StockConnectionString");
private string _CommandName;
_CommandName = "sp_LoadScript";
DbCommand dbCommand = db.GetStoredProcCommand(_CommandName);
db.AddInParameter(dbCommand, "Name", DbType.String, "abc");
db.LoadDataSet(dbCommand, Crystal, "script");

here sp_Loadscript is a sql server 2005 stored procedure which load
script.
Share:

Starting PageCounter to Specific Value in ASP

Here is a code that start value to a specific value.
In the code i have started its value from 10000

Dim objPageCount
Set objPageCount = Server.CreateObject("MSWC.PageCounter")
objPageCount.PageHit()

dim hit
hit=objPageCount.Hits()+ 10000
Response.Write "Site Visitors: " & hit & ""

Happy Programming
Share:

Tired of Finding Jobs- Don't Give Up

If you are finding jobs for a long time and you are not getting interview calls from companies then just don't give up just keep trying. Here is a post for you that will inspire you on this.

http://aliabdin.wordpress.com/2006/12/09/determination-drive-and-passion/
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews