Saturday, November 5, 2011
interface IA
{
void Goto();
}
class mybase
{
void Goto()
{
Console.WriteLine("inside mybase constructor.");
}
}
What is the output of the following code block ?
class myderived: mybase, IA
{
}
a) Does it compiles successfully? or Does it throw any error?
b) Do we need to provide definition of method Goto() in class A()?
Q2. Do we need to define method named Goto() in class "myderived"? or that is not needed ? consider following code?
interface IA
{
void Goto();
}
interface IB
{
void Goto();
}
class mybase
{
public void Goto()
{
Console.WriteLine("inside mybase constructor.");
}
}
class myderived: mybase ,IA
{
// Does this code compile and run successfully?
}
a) Does this code compile and run successfully?
b) What happens if the keyword "public" is removed from Goto() method defination in "mybase" class?
c) What happens when in interface "IB", the signature of the method "void Goto()" is changed to some other say "int Goto()" keeping everything same? Does "myderived" is compiled successfully or it throws any error?
Thursday, February 17, 2011
How To Drop Already Created Index in a sdf file(SQL CE)
The problem of deleteing/droping an already created index in a table in sdf file is that (1) if you have opened it in SQL Server 2005 editor or (2) using Visual Studio editor, you can not just delete/drop the index though both editor provides you an option for deleteing / droping using content menu item.
The bottom line is, you just can not delete/drop an already created Index in a table in sdf file using either SQL Server 2005 editor or Visual Studio editor.
An already created Index in a table in sdf file can only be dropped/deleted using a query as explained following,
=========================================================
DROP INDEX
Where "TABLE_NAME"
=========================================================
Example : If you have a table named "CUSTOMER_POSM_REQUEST" and already existing Index name is "RECORD_ID_INDEX" then as mentioned above, the query would be like this:
DROP INDEX CUSTOMER_POSM_REQUEST.RECORD_ID_INDEX
=========================================================
Use the above query and run the query in either of the editor mentioned above. Index will be deleted. Not sure what is the reason behind that. Need to dig it further :)
Tuesday, August 31, 2010
Microsoft Interview Questions
-------------------------------------------------------------
public class A
{
public A()
{
B objB = new B();
Console.WriteLine("A constructor.")
}
}
public class B
{
public B()
{
A objA = new A();
Console.WriteLine("B constructor");
}
}
static void main()
{
A objNewA = new A();
}
---------------------------------------------------
Q: What would be output of the above code when executed? (C# code)
2. What is ASP.NET pipeline?
3. Say you have a milion of record need to be cached for your ASP.NET web application. What would be available options for caching mechanism considering fast access and critical data?
4. In case your answer is "StackOverflow exception happens" for question number 1, then tell us why exception type is "StackOverflow" because as it is seen in the code, that both A and B's constructors are creating new instances of type A/B and new objects are stored in "heap" and not on "Stack". Why it is still then "StackOverflow exception"????
There are couple of more questions too. But I need to memorise it. I would post them as soon as I remember and frame it correctly.
Happy reading !!!!
Cheers,
Monday, October 5, 2009
VC++ in VS 2008 - Part 2- Adding a cpp file having code
Therefore I have(1) "VCApp.cpp" having "main" function. (2) "A.cpp" is new file name where I want to add my class A. And then I want to access that class in my main function.
Following is my defination of class "A" which I want to put in "A.cpp"
public class A{
public:
A()
{
Console::WriteLine("Inside A constructor.");
};
};
and I access the class A in my main function as following way ,
int main(array
{
A* o = new A();
return 0;
}
I put above code and while building, found following compile time error(s),
----------------------------------------------------------------------------------
fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
error C2065: 'A' : undeclared identifier
error C2065: 'o' : undeclared identifier
error C2061: syntax error : identifier 'A'
----------------------------------------------------------------------------------
To get around of this error (1) Add the following line in A.cpp at the top of it.
#include "stdafx.h"
(2) Add the following line to the top of "VCApp.cpp" file,
#include "A.cpp" ---- adding this line helps compiler to refer defination class A to find in "A.cpp" file.
Now if I compile the code then there is no compile time error and I got following out put in my console output,
Inside A constructor.
Press any key to continue . . .
Happy coding !!!
Exploring VC++ in Visual Studio 2008
I created a new Project from File->New ->Project -> CLR Console Application then I gave a name "VCApp".
In the project solution I can see that "VCApp.cpp" is the file where I can add my code/any custom written class.
When I have added a custom class named "A". Following is my code for my custom class,
public class A
{
public:
A()
{
Console::WriteLine("Inside A constructor.");
}
}
Though above is a very simple code snippet I was surprised to see following compile time errors
---------------------------------------------------------------------------------------
error C2628: 'A' followed by 'int' is illegal (did you forget a ';'?)
error C3874: return type of 'main' should be 'int' instead of 'A'
error C2664: 'A::A(const A &)' : cannot convert parameter 1 from 'int' to 'const A &'
---------------------------------------------------------------------------------------
I just did a quick inspection in my code then then found that code needs the scope termination operator ";" in proper places. So I modified as following ,
public class A{
public:
A()
{
Console::WriteLine("Inside A constructor.");
};
} ;
Just added a semicolon (1) while closing at end of constructor and (2) End of class and I found the build was succeeded.
Wednesday, August 19, 2009
The value violated the integrity constraints for the column.
The value violated the integrity constraints for the column.".(SQL Server Import and Export Wizard)"
Tuesday, October 21, 2008
====================================================================
declare dt date;
pp varchar(100);
begin
dt:=TO_DATE('2008/04/25', 'yyyy/mm/dd');
select CEIL((SYSDATE - 180) - Decode(dt,null,(SYSDATE - 180),dt)) into pp from dual;
dbms_output.PUT_LINE(pp);
end;
Monday, September 22, 2008
Lyrics of Oho kiku eruthe
Movie name:Padiyappa
Starring: Rajanikanth, Soundarya
Music: A R Rahman
Singer: SPB
Language: Tamil
ohoho kicku yerudhe
ohoho vetkam ponadhe
uLLukkuley nyaanam oorudhe
uNNmai ellaam solla thonudhe
verum kampangali thinnavanum mannukkuLLa
ada thangapaspam thinnavanum mannukkuLLa
indha vaazhkai vaazha thaan
naam pirakkayil kaiyil enna kondu vandhom kondhu sella?
(ohoho..)
paNaththai pooti vaithai
vairathai pooti vaithai
uyirai poota edhu pootu?
kuzhandhai nyaani, indha iruvarai thavira
inge sugamaai iruppadhu yaar kaatu
jeevan irukkummattum
vaazhkai namadhumattum
idhudhaan nyaanasidhdhar paatu
indha bhoomi samam namakku
nam theruvukkuL
madasandai jaadhidsandai vambyerdharkku?
(ohoho...)
thaayai therndhekkum
thandhayai therndhekkum
urimai unnidhathil illai
mugaththai therndhekkum
niraththai therndhekkum
urimai unnidhathil illai
pirappai therndhekkum
irappai therndhekkum
urimai unnidhathil illai
eNNi paarkkum vELaiyil
un vaazhkai mattum
undhan kaiyil undu
adhai vendridu!
Friday, September 5, 2008
How to use TOAD for to write oracle PL SQL?
1. Multiple SELECT statement can not be executed in TOAD
2. Simplest PL/SQL code in TOAD
DECLARE iDocID NUMBER(6);
BEGIN
SELECT COUNT(*) INTO iDocID FROM TBL_TW_DOCS;
DBMS_OUTPUT.PUT_LINE(iDocID);
END;
3. If a statement is returing more than one value(i.e rowset), then we can not execute using BEGIN and END.
Therefore,following code does not execute in TOAD and thows error:
a) Click on new procedure window.
d) Click on filter button and following screen appears where user is allowed to filder by package name or SP name
Thursday, August 21, 2008
Inserting into database using SqlBulkCopy Class (c#)
SqlBulkCopy:
SqlBulkCopy class which has been introduced .NET2.0 onwards allows bulk insertion into Sql Server database.
Limitation of using SqlBulkCopy:
1. Only insertion is allowed. We can not achive updation any single row of databse (sql server) while using SqlBulkCopy class.
2. We can insert into SqlServer database only.
3. While inserting into db, SqlBulkCopy does not do any validation. SqlBulkCopy takes data "as is" and tries to insert data into Sql Server database.
For an example, say if you have column of type DateTime in Sql Server database. While using SqlCommand a string value is aumatically converted into DateTime in database. But in same scenario SqlBulkCopy fails.
If you have datatime column in Database, in memory also you need to have a datetime type column.
The bottomline is : SqlBulkCopy does not do any data validation or conversion for you. Therfore using SqlBulkCopy class error creps in frequently. Programmer need to take care of data validation also.
Advantage of SqlBulkCopy:
It inserts values much faster way that any other.
Programming Scenario:
You may come across following programming scenario
------------------------------------------------------------------------
Data source_____ Data destination
------------------------------------------------------------------------
1. A table in Sql Server_-----A table in Sql Server
------------------------------------------------------------------------
2. In memory----------------------------------------------------
--data representation-----------------------------------------
i.e. a DataTable object--------A table in Sql Server--
------------------------------------------------------------------------
3.Oracle or------------------ ------------------------------------
Other database-------------------A table in Sql Server
------------------------------------------------------------------------
4. Sql Server-----------------------A table in Sql Server
------------------------------------------------------------------------
Following is code shown for programming scenario 2
Assumtion:
1. "dtLog" is a DataTable with data.
2. Sql Server database table name is stored into app.config file.
3. Sql Server database table structure is like following
The table is having a identity column: RowID
3. UpdateDatbase() function takes the a DataTable object as parameter and inserts all rows
into Sql Server DataBase.
CODE:
private void UpdateDatabase(DataTable dtLog)
{
SqlBulkCopy bulkCopy = null;
Stopwatch sw = new Stopwatch();
sw.Start();
SqlBulkCopyColumnMapping map1 = null, map2 = null, map3 = null, map4 = null, map5 = null, map6 = null, map7 = null, map8 = null, map9 = null, map10 = null, map11 = null, map12 = null,map13 = null;
try
{
bulkCopy = new SqlBulkCopy (Settings.Default.DBConnString ,SqlBulkCopyOptions.KeepIdentity);
map1 = new SqlBulkCopyColumnMapping("EngagementId", "EngagementId");
map2 = new SqlBulkCopyColumnMapping("EngagementName", "EngagementName");
map3 = new SqlBulkCopyColumnMapping("SyncGroup", "SyncGroup");
map4 = new SqlBulkCopyColumnMapping("SyncStartTime", "SyncStartTime");
map5 = new SqlBulkCopyColumnMapping("ClientSelectChangeStart", "ClientSelectChangeStart");
map6 = new SqlBulkCopyColumnMapping("ClientSelectChangeEnd", "ClientSelectChangeEnd");
map7 = new SqlBulkCopyColumnMapping("ServerApplyChangeStart", "ServerApplyChangeStart");
map8 = new SqlBulkCopyColumnMapping("ServerApplyChangeEnd", "ServerApplyChangeEnd");
map9 = new SqlBulkCopyColumnMapping("ServerSelectChangeStart", "ServerSelectChangeStart");
map10 = new SqlBulkCopyColumnMapping("ServerSelectChangeEnd", "ServerSelectChangeEnd");
map11 = new SqlBulkCopyColumnMapping("ClientApplyChangeStart", "ClientApplyChangeStart");
map12 = new SqlBulkCopyColumnMapping("ClientApplyChangeEnd", "ClientApplyChangeEnd");
map13 = new SqlBulkCopyColumnMapping("SyncEndTime", "SyncEndTime");
bulkCopy.ColumnMappings.Add(map1);
bulkCopy.ColumnMappings.Add(map2);
bulkCopy.ColumnMappings.Add(map3);
bulkCopy.ColumnMappings.Add(map4);
bulkCopy.ColumnMappings.Add(map5);
bulkCopy.ColumnMappings.Add(map6);
bulkCopy.ColumnMappings.Add(map7);
bulkCopy.ColumnMappings.Add(map8);
bulkCopy.ColumnMappings.Add(map9);
bulkCopy.ColumnMappings.Add(map10);
bulkCopy.ColumnMappings.Add(map11);
bulkCopy.ColumnMappings.Add(map12);
bulkCopy.ColumnMappings.Add(map13);
bulkCopy.DestinationTableName = Settings.Default.DBTableName.Trim();
bulkCopy.WriteToServer(dtLog);
}
catch (Exception ex)
{
errorCount++;
ApplicationLog(String.Format("Exception in UpdateDatabase. Message : {0},StackTrace {1}", ex.Message, ex.StackTrace));
}
finally
{
sw.Stop();
bulkCopy = null;
txtResult.Text = (sw.ElapsedMilliseconds / 1000.00).ToString();
map1 = null; map2 = null; map3 = null; map4 = null; map5 = null; map6 = null; map7 = null; map8 = null; map9 = null; map10 = null; map11 = null; map12 = null; map13 = null;
}
Friday, July 18, 2008
OOPs with C# - Session 1
A class is a basic building block of object oriented programing.
Syntax:
{
}
Regarding access modifier of class:
class access modifier = {public,protected,private}
1. In most cases we mention public or protected to be the access modifier of a class. Very few case we can encounter where we mention private to be access modifier of a class.
Q. What happens if we declare a class private?
How Object Oriented Programming came into picture
----- Structured programming can be seen as a subset or subdiscipline of procedural programming, one of the major programming paradigms.
----- At a low level, structured programs are often composed of simple, hierarchical program flow structures. These are regarded as single statements
______________Programming Paradigm
_______________________|
_______________________|___________________
___|_______________________________________|
Unstructured Programing________________ structured Programing
___________________________________________|
___________________________________________|_________________
____________________|________________________________________|
___________Procedural Programing ___________________ Object Oriented Programing
1. Unstructured Programing: Most simplest way of doing programing. Just sequence of instructions to be executed to achieve the task.Does not follow any structure(no program structure and no data structure). So there is no methods or procedure in this kind of programing.
2. Structured Programing: This solicites for a breaking the whole task into multiple subset of instruction. This subsets are methods or procedure.
Advantage over Unstructured Programing:
1. Better Code maintanace
2. Better Reusability of code
3. Object Oriented Programing
Consider all real life entities as objects.
Introduces concepts of class.
Advantage over Unstructured Programing:
1. Better code reusuability
2. Better code maintanence
3. Data Encapsulation
4. Data hiding
Comparision:
| | Unstructured Programing | Structured Programing | Object Oriented Programing |
| code reusuability | less | medium | more |
| code maintanence | Most difficult | medium | Most easier |
| Data Encapsulation | No | No | Yes |
| Data hiding | No | No | Yes |
Fix: Please do the following steps
1. From menu, select Tools then Options.
2. Once options is clicked following screen appears.
3. Select General under Debugging
4. Uncheck the checkbox beside Want if no user code on launch.
Monday, June 23, 2008
Finally Puzzle !!!
As usual I was trying to play with try catch block of .NET 2.0 today ..( hey guys I am assureing you that its not going to be another nerd's den of .NET) and loved to see that agian I was forgetting some key points of that !!!
Just to summarise what I am going to put together, consider the following code snippet ...
try
{
// any code here
}
finally
{
Console.WriteLine("String Value 1");
Console.WriteLine("String Value 2");
}
try
{
// any code here
}
finally
{
Console.WriteLine("String Value 1");
}
Console.WriteLine("String Value 2");
Tuesday, January 29, 2008
Singer: Minmini, Shubha
Bakthi Paadal Phadattuma
Paalum Thenum Odattuma
Santhosham Kaanbhoma
Samikku Pushpangal Vendaama
Sambo Sambo Sambo Sambo
Sayangalam Vambo Vambo
Boomi Thandi
Pogamal
Saagamal Mothchangal Kanbom Ippo
Utchi Megam Ennai Parthathum
Konjam Neer Senthum Allava
Uppu Katru Ennai Theendinaal
Satre Thithikkum Allava
Ennai Pen Kettu Caesar Vanthaan
Endhan Pinnale Hitler Vanthaan
Yaarum Illatha Nerathilae
Sollamal Bramman Vanthaan
Medai Pottu Methai Kollavae
Jadai Seithale Podhumae
Engal Veetu Kashmir Kambali
Iruvar Kulirthanga Koodumae
Indha Mogathil Enna Kutram
Kadal Yogathin Utcha Kattam
Andha Sorgathil Saerkattuma
Inndraikku Unnai Mattum
NB : Thanks to http://www.mohankumars.com where I found the above lyrics.
Sunday, December 9, 2007
Tamil Lyrics
I am posting here tamil lyrics of some good tamil song ... hope other Non Tamil friends who love tamil movie songs will help them a lot ..
Movie: Deeapavali Song : Poogathe
Music: Yuvan Shakar Raja
Pogadhe pogadhe nee irrunthaal naan irrupen
Pogadhe pogadhe nee pirinthaal naan irrapen
Unnoda vaalntha kaalangal yaavum kanavai ennai mooduthadi
Yyaar endru neeyum enna paarkum pothu uyrai uyire poguthadi
Kalaraiyil kuda jannal ondru vaithu undhan mugham paarpenadi
Pogadhe pogadhe nee irrunthaal naan irrupen
Pogadhe pogadhe ee pirinthaal naan irrapen
Kalainthalum megham athu meendhum medhakum
Adhu pola thaaney undhan kadhal ennakum
Nadai padhai vilaka kadhal viluntha uddan nadaipathuku
Nerupalum mudiyath amma nineivugalai allipathuku
Unnakaga kathirrupen oh
Uyirodu paarthirrupen oh
Pogadhe pogadhe nee irrunthaal naan irrupen
Pogadhe pogadhe nee pirinthaal naan irrapen
Alagana neram adhai neethaan kudduthai
Aliyatha sogam athaiyum nee thaan kudduthai
Kan thoogum neram paarthu kadavul vanthu ponathu pol
Yen vaalvil vanthei aanai yemathru thaangavillaiye
Pennai nee illamal ..... Bhoologam irrutiruthei
Pogadhe pogadhe nee irrunthaal naan irrupen
Pogadhe pogadhe nee pirinthaal naan irrapen
Movie: Deeapavali Song : Poogathe
Music: Yuvan Shakar Raja
Kadhal Vaithu Kaathal vaithu, kaathal vaithu kaathirunthen
Kaatril unthan kural mattum keatirunthen
Sirithaai isai arinthen Nadanthaai dhisai arinthen
Kaathal enum kadalukkul naan vizhunthen
Karaiyinil vantha pinnum naan mithanthen Asainthaai anbey asainthen Azhagaai aiyo tholainthen
Kaathal vaithu, kaathal vaithu kaathirunthen Kaatril unthan kural mattum keatirunthen
Asainthaan anbey asainthen Azhagaai aiyo tholainthen
Devathai kathaiiii keattapothellaaaam, nijam endrun ninaikkavillaiiiiii
Neril unnaiyeyyy paatha pinbu naaaaan, nambi vitten marukkavillaiiiiiii
Athikaalai vidivathellaaaam, unnai paarkkum mayakkathilthaaaan
Anthi maalai maraivathellaaaam, unnai paartha thirakkathilthaaaan
Kaathal vaithu, kaathal vaithu kaathirunthen
Kaatril unthan kural mattum keatirunthen
Asainthaan anbey asainthen Azhagaai aiyo tholainthen
Unnai kanda naaaazh ozhi vattam pol, ullukkulley suzharuthadiiiiiiii
Un idathil naan pesiyathellaaaam, uyirukkul ozhikkuthadiiiiiiiiiii
Kadalodu pesa vaithaaiiiiiii
Kadigaram veesa vaithaaiiii
Mazhaiodu kuzhikka vaithaaiiiiii
Veyil kuda rasikka vaithaaiiiiiiiiii
Kaathal vaithu, kaathal vaithu kaathirunthen
Kaatril unthan kural mattum keatirunthen
Sirithaai isai arinthen Nadanthaai dhisai arinthen
Kaathal enum kadalukkul naan vizhunthen
Karaiyinil vantha pinnum naan mithanthen
Asainthaai anbey asainthen
Azhagaai aiyo tholainthen
Asainthaai anbey asainthen
Azhagaai aiyo tholainthen
Saturday, November 17, 2007
In Bangalore ...
Karnataka has always been a nice and beautiful to me .....
I had quite a few friends over when I stayed there in Thavarekere, Bangalore .... The big boon I had was just a bike .... every time ... BROOOOOOMMMM ... go whereever you want ... whenever ...
There was Sherin Mathew, my company collgues and friend .... we used to comeback after having a very very hectic day at office ..... We were really good friends and enjoyed a lot those day ...
Frankly speaking I learned a lot with Sherin ..... atleast Javascript !!! What Sherin what say ?;-)
But it was roommate Sourav with whom I spent some most cherishable and enjoyable moments of my life. There is Madan Pub story .... Nandi Hill program .... Sanky Tank vigil ...... enjoying riding over Outer Ring Road .... Rajarajeswari Temple Tour .... Visiting Ragikutta Temple .....
and the lists goes on and on ....
Wish you very best my friends ....
Hope to come to Bangalore as many times as possible. Lets see ... !!!
Thursday, October 4, 2007
Regular Expression
(\\s+\\b?)
To make optional : regular expression followed by "question mark" i.e. (regex?)
Example
string strPattern = "aaa(b?)ccc"
Matches "aaaccc" and "aaabccc" both
Wednesday, August 22, 2007
Full Text Indexing in SQL SERVER 2005 using for PDF files
Uploading PDF files to SQL Server 2005 databse and Index them using full text index.
Analysis:
Since PDF files can be very big .... the best option is to save the PDF contents in a database table column of TYPE VARBINARY(MAX)
So create a table docs that having a
docs
DocID(int)
DocContents(varbinary(max))
DocType(varchar(10))
Now the third column DocTYpe is needed to tell full text index engine what kind of file we are going to search through.
[Basically in SQL SERVER 2005, full text search engine stores the in-built seaching indexs for known types. What are the in-built file types that can be full text indexed can be fount using a view named "sys.fulltext_document_types"
So Execute "select * from sys.fulltext_document_types" in your database to see what are the in-built available type for FTS. Normally you would not find an entry ".pdf" in the result set if the above mentioned query.
]
You need to install ADOBE PDF IFILTER 6.0 that is compatible to ADOBE PDF 7.0 version.
Then you need to load the features of the ADOBE IFILTER6.0
FTS your table.
Execute the FTS query.
So
STEP 1:
1. Execute the query "select * from sys.fulltext_document_types" to check whether ".pdf" exists in "document_type" column in the resultset.
2. If ".pdf" does not exists in "document_type" column in the resultset then
3. Download the ADOBE IFitler 6.0 and installt it. It helps SQL SERVER 2007 for indexing PDF files.
4. Now we need to load the installed ADOBE IFILTER 6.0 in our SQL SERVER 2005 so that we can FTS PDF files. For that execute the following SPs sequencially.
exec sp_fulltext_service 'verify_signature', 0
exec sp_fulltext_service 'load_os_resources',1
5. Now please execute select * from sys.fulltext_document_types and make sure that an entry ".pdf " is there in "document_type" column in the resultset
Sunday, July 8, 2007
Love is PART of life NOT HEART of life
Just saw today ... Taj was selected among new seven wonders .... as it is the greatest symbol of - Love & Passion! ...... Thanks to Mogul Great Shahajahan having built this awesome monument ...... I was thinking whether I would do such a thing as Great Shahajan did.
Nope ....... Because love is not the heart of life ... just a part of life ......
