Posts

Prepare DTO layer by using below script

DECLARE @CurID INT, @MaxID INT Declare @sql nvarchar(MAX) Declare @TmpTable table (ID int Identity(1,1), c_Column_name varchar(500),c_Data_type varchar(50),c_character_Maximum_length nvarchar(50)) Insert into @TmpTable (c_Column_name,c_Data_type,c_character_Maximum_length)     SELECT COLUMN_NAME ,DATA_TYPE ,CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TT_M_User'  --Table Name ORDER BY ORDINAL_POSITION ASC; set @CurID = 1 set @sql='' SELECT @MaxID=Max(ID) FROM @TmpTable WHILE @MaxID >=@CurID BEGIN -- Logic to be performed select @sql = @sql + char(13)+ ' public ' +     case c_Data_type     when 'varchar' then ' string '     when 'nvarchar' then ' string '     when 'bit' then ' bool '     when 'datetime' then ' DateTime '     when 'binary' then ' Byte[] '     else c_Data_type end + ' ' + c_Column_Name + ' {get;set;} 

ASP.NET : Difference between Server.Transfer and response.Redirect

Response.Redirect sends message to the browser saying it to move to some different page, while server.transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in server.transfer there is no round trip while response.redirect has a round trip and hence puts a load on server. Using Server.Transfer you can not redirect to a different from the server itself. Example if your server is www.yahoo.com you can use server.transfer to move to www.microsoft.com but yes you can move to www.yahoo.com/travels, i.e. within websites. This cross server redirect is possible only using Response.redirect. With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page. Use server.transfer to navigate within website. And use Response.redirect to redirect to another website. You can transfer current users page request to another page with

DBCC CHECKIDENT

Question Which command is used reseed the identity value? Answer DBCC CHECKIDENT can be used to manually set a new current identity value for the identity column. DBCC CHECKIDENT ("Sales.ProductType", RESEED, 10);

Quickest way to SELECT All Columns from a Table

Suppose you have a huge table which has say 30-40 columns and you want to select all of them or most of them say around 30 columns. It is a tedious job to type each of the column names. Here is a quick way to get a comma separated list of all the columns with minimal effort. Go to SSMS, Open a new query window, Type SELECT followed by a space Go to Object Explorer Expand the databases node, expand the user database which contains your table, expand the Tables folder, Expand the Table from which you need to selec the Columns/Data. Click on "Columns" folder, hold it, and drag it on to the Query Surface after the "SELECT " (Step 1). This place all the columns on to the query surface in a comma separated fashion. Remove the unwanted columns Now type in " FROM TableName" at the end of the column list (Outcome of Step 4 & 5) and do the necessary formatting. It is as simple as that ! This can save a lot of effort required to manually type in the Column

Find Excel Workbook available sheet name using asp.net c#

hi friends, today morning i find one issues to find available sheet in Excel workbook.. so here is solution for this. first of all we has to upload that file to server [excel] folder and then read excel sheet with oledb provider. 1. create aspx page with having two controls      File upload controls with name [flUpldExcel]      One command button to perform action.  than once we save excel sheet to server so next step is to find available sheet in work book. Now want to find available sheets on workbook. for that i write code that will find all sheets. Code for saving file on server  try         {             string strFilePath = Server.MapPath("excel") + @"\";             string strFileName = string.Empty;             if (flUpldExcel.HasFile)             {                 strFileName = flUpldExcel.PostedFile.FileName;                 flUpldExcel.SaveAs(strFilePath + strFileName);                 string[] strSheetName;                 strSheetName = GetEx

How to find a table when you don't know which database it belongs to?

In this very short tip I'd like to share my solution to a yesterday quesiton in MSDN forum - how to find the database the table belongs to. I use my favorite idea of dynamically constructing a query using INFORMATION_SCHEMA.TABLES view. DECLARE @table sysname, @SQL NVARCHAR(MAX) SET @table = 'Items' SET @SQL = '' SELECT @SQL = @SQL + '; IF EXISTS (SELECT 1 from ' + QUOTENAME(name) + '.INFORMATION_SCHEMA.Tables WHERE Table_Name = @table AND TABLE_TYPE = ''BASE TABLE'') PRINT ''Table ' + @table + ' found in ' + name + '''' FROM sys.databases   EXECUTE sp_executeSQL @SQL, N'@table sysname', @table That's all. Try it with the table which you may have in multiple databases. I used a bit undocumented way of concatenating multiple rows in a string, so I can not actually use ORDER BY in this code. To be strict, I need to use XML PATH('') approach here instead.

15 GREAT THOUGHTS BY CHANAKYA

Image
1) "Learn from the mistakes of others... you can 't live long enough to make them all yourselves!!" - Chanakya 2)"A person should not be too honest. Straight trees are cut first and Honest people are screwed first." - Chanakya 3)"Even if a snake is not poisonous, it should pretend to be venomous." Chanakya 4)"There is some self-interest behind every friendship. There is no friendship without self-interests. This is a bitter truth." - Chanakya                                                              5)" Before you start some work, always ask yourself three questions - Why am I doing it, What the results might be and Will I be successful. Only when you think deeply and find satisfactory answers to these questions, go ahead." - Chanakya 6)"As soon as the fear approaches near, attack and destroy it." - Chanakya 7)"The world's biggest power is the youth and beauty of a woman." - Chanakya