Wednesday, August 17, 2011

How to: Modify Column Data Types (Visual Database Tools)

To modify the data type of a column


1.In Object Explorer, right-click the table with columns for which you want to change the scale and click Design.
The table opens in Table Designer.

2.Select the column for which you want to modify the data type.

3.In the Column Properties tab, click the grid cell for the Data Type property and choose a new data type from the drop-down list.

The new data type is assigned to the column after you click outside the grid cell or use the TAB key to move to another grid cell. It takes effect in the database when you save your changes in Table Designer.

Some time it does not work. Especially if there is a table dependancy (constraints ) and data.
So that time, run the script.

ALTER TABLE table ALTER COLUMN column_name new_data_type


Example .
ALTER TABLE MyTable ALTER COLUMN MyColumn NVARCHAR(100)

Saturday, August 6, 2011

Get job in TCS ... Just in INR 14,700..... Beware of spam emails...


Hard to believe but it's true, people started this business. Today morning,  I received email stating the same.
According to email,  I suppose to deposit a cash of 14,700/-(Fourteen thousand Seven hundred rupees) as an initial amount, and I'll get guaranteed job in TCS.

In order to, aware people around and request not to believe in all these craps. Immediately report, If you come across any consultancy\agency doing business , putting all these toppings of deposit security amount.
Exactly, gluing the email, I received.


Here's the email detail

fromtataconsultancy Service tataconsultancyservice_2011@hotmail.com
reply-totataconsultancyservice_2011@hotmail.com
toinfo@tata.com
dateSat, Aug 6, 2011 at 3:51 AM
subject Dear Applicant...


Tata Consultancy Services(TCS)
5th Floor, PTI Bldg., 4, Parliament
Street New Delhi - 110 001.
Email:tataconsultancyservice_2011@hotmail.com

REF: "TATA CONSULTANCY SERVICE" DIRECT RECRUITMENTS OFFER.

Your Resume has been selected from JOB SEEKERS DATA BASE for our new plant. The
Company selected 62 candidates list for Senior Engineer, IT, Administration,
Production, marketing ,Retail and general service Departments. It is our pleasure to inform
you that your Resume was selected as one of the 62 candidates shortlisted for the interview.

Tata Consultancy Services(TCS)  is involved for Senior Engineer, IT, Administration,
Production, marketing ,Retail and general service Departments in India; The
Company is recruiting the candidates for our new plants in Delhi, Bangalore, Pune.Hyderabad
Kolkata ,Chennai and Mumbai. Your interview will be held at The Company Corporate office in
New Delhi on 21th Of August at 11.30am, we are  pleased to inform you that the
62 candidate’s selected 56 candidates will be giving appointment, meaning your Application can be in progress to the final stage. You will have to come to the Company corporate office in New Delhi. Your offer letter with Air Ticket will be sent to you by courier before date of interview. The Company can offer you a salary with benefits for this post 65, 000/- to 200, 000/- P.M. + (HRA + D.A + Conveyance
and other Company benefits. The Designation and Job Location will be fixing by Company HRD. At time of final process. You have to come with photo-copies of all required documents.

REQUIRED DOCUMENTS BY THE COMPANY HRD
======================================
1) Photo-copies of Qualification Documents.
2) Photo-copies of Experience Certificates (If any)
3) Photo-copies of Address Proof
4) Two Passport
======================================
1. Full Names:
2. Contact Address:
3. Mobile Number:
4. Sex:
5. Age:
======================================
You are to deposit a cash of 14,700/-(Fourteen thousand Seven hundred rupees) as an initial amount in favour of our Company accountant name in charges to collect your payment. Payment for the Rs. 14,700/- (Fourteen thousand Seven hundred rupees) through any [STATE BANK OF INDIA]
(AXIS BANK) OR [ICICI BANK] Branch from your Home City to our Company accountant name in charge. Account NO,  which will be sending to you upon your response. This is a refundable interview security deposit.  Your offer letter With Air tickets will be send to your Home Address by courier after receiving  The confirmation of interview security deposit. This Company will pay all the expenditure to you at the time of face-to-face meeting with you in our corporate office. The Job  profile, salary offer, and date -time of interview will be mention in your offer letter.
Your offer letter will dispatch very shortly after receiving your confirmation of cash deposited in STATE BANK OF INDIA,AXIS BANK OR ICICI BANK. We wish you the best of  luck for the subsequent and remaining stage. The last date of security deposited in  bank  13th Of August 2011 you have to give the information after deposited the Security amount in bank to the Company HRD -direct recruitment via email.

Your Letter with supporting document will be dispatch same time by courier to your postal address after receipt of security deposit confirmation in bank. The interview process and arrangement expenditure will be paid by Tata Consultancy Services(TCS). Lodging, travelling and local conveyance actual will be paid by Tata Consultancy Services(TCS) as per  bills. The candidate has to deposit the initial refundable security as mentioned by HRD.
NB: You are advice to reconfirm your mailing address and phone number in
your reply. And 14,500/- (Fourteen thousand Five hundred rupees) will be the refundable
Amount, as 200 rupees will be deducted as bank charges for funds deposit. And if
you are been selected or not, still the amount will be refunded to you, as the amount
is just to prove that you will be coming for the interview in order for us not to run at
lost after sending you the air ticket and you don't show up on the day of interview.
Wishing you the best of lucks.


Regards,
Mr.Sai Kumar Patil
SENIOR H.R MANAGER


Please be aware of this kind of emails. And please help me to let other people aware. Immediately report,  if by chance, anyone of you come to know about  the originators of this kind of business.

I heard, another fraud agency of this kind was doing the similar business , in the name of Wipro.

Big Giant like Wipro and TCS has a moral responsibility for society to find out the agencies doing this sort of business or at least make people aware about the frauds (using their reputed names).

Even though, I'm educated, but at first instance, reading first paragraph, It impress me like it's through HR TCS. Later on,  I understood this is a spam. Imagine the desperate and a person-in-need could definitely  believe on this.

If you read the email carefully, you would find it funny, indeed. I'll help you by highlighting the stuffs.
"Your offer letter with Air Ticket will be sent to you by courier before date of interview."
wow , great deal isn't it. But very hard to believe.

Look the document this stupid required.

REQUIRED DOCUMENTS BY THE COMPANY HRD
======================================
1) Photo-copies of Qualification Documents.
2) Photo-copies of Experience Certificates (If any)
3) Photo-copies of Address Proof
4) Two Passport
======================================
Great, they need two passport of mine.

Look at this, now they need money.

"You are to deposit a cash of 14,700/-(Fourteen thousand Seven hundred rupees) as an initial amount in favour of our Company accountant name in charges to collect your payment. Payment for the Rs. 14,700/- (Fourteen thousand Seven hundred rupees) through any [STATE BANK OF INDIA] (AXIS BANK) OR [ICICI BANK] Branch from your Home City to our Company accountant name in charge. Account NO, which will be sending to you upon your response."

Read more,

"Your offer letter will dispatch very shortly after receiving your confirmation of cash deposited in STATE BANK OF INDIA,AXIS BANK OR ICICI BANK"

"This Company will pay all the expenditure to you at the time of face-to-face meeting with you in our corporate office."


Please help society to find out the existence of these kind of people or business. TCS, WIPRO must have done something as their reputed name has been used. Here's they are directly using the TCS office corporate office address.

I'm jotting all this to aware people around and request not to believe in all these craps. Immediately report, if you come across any consultancy\agency doing such business (of putting all the toppings) of deposit security amount. I know there are so many consultancy running, who ask you to deposit some money to provide job.

If any responsible body is seriuos and would really like to investigate against these sort of fake agencies to expose them . Being a responsible  citizen I can help by forward the email which I have received today itself
(6th Aug 2011).

 
One last request , dont believe in all these. Just believe in your self  and apply for job online.

Enjoy and Good Wishes.


Friday, August 5, 2011

SCOPE_IDENTITY() vs. @@IDENTITY - Retrieving Identity for Most Recently Added Row in Table

Returns the last identity value inserted into an identity column in the same scope. A scope is a module: a stored procedure, trigger, function, or batch. Therefore, two statements are in the same scope if they are in the same stored procedure, function, or batch.



SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY are similar functions because they return values that are inserted into identity columns.
IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the value generated for a specific table in any session and any scope. For more information, see IDENT_CURRENT (Transact-SQL).
SCOPE_IDENTITY and @@IDENTITY return the last identity values that are generated in any table in the current session. However, SCOPE_IDENTITY returns values inserted only within the current scope; @@IDENTITY is not limited to a specific scope.
For example, there are two tables, T1 and T2, and an INSERT trigger is defined on T1. When a row is inserted to T1, the trigger fires and inserts a row in T2. This scenario illustrates two scopes: the insert on T1, and the insert on T2 by the trigger.
Assuming that both T1 and T2 have identity columns, @@IDENTITY and SCOPE_IDENTITY will return different values at the end of an INSERT statement on T1. @@IDENTITY will return the last identity column value inserted across any scope in the current session. This is the value inserted in T2. SCOPE_IDENTITY() will return the IDENTITY value inserted in T1. This was the last insert that occurred in the same scope. The SCOPE_IDENTITY() function will return the null value if the function is invoked before any INSERT statements into an identity column occur in the scope.
Failed statements and transactions can change the current identity for a table and create gaps in the identity column values. The identity value is never rolled back even though the transaction that tried to insert the value into the table is not committed. For example, if an INSERT statement fails because of an IGNORE_DUP_KEY violation, the current identity value for the table is still incremented.

SELECT @@IDENTITY
It returns the last IDENTITY value produced on a connection, regardless of the table that produced the value, and regardless of the scope of the statement that produced the value.
@@IDENTITY will return the last identity value entered into a table in your current session. While @@IDENTITY is limited to the current session, it is not limited to the current scope. If you have a trigger on a table that causes an identity to be created in another table, you will get the identity that was created last, even if it was the trigger that created it.
SELECT SCOPE_IDENTITY()
It returns the last IDENTITY value produced on a connection and by a statement in the same scope, regardless of the table that produced the value.
SCOPE_IDENTITY(), like @@IDENTITY, will return the last identity value created in the current session, but it will also limit it to your current scope as well. In other words, it will return the last identity value that you explicitly created, rather than any identity that was created by a trigger or a user defined function.
SELECT IDENT_CURRENT(‘tablename’)
It returns the last IDENTITY value produced in a table, regardless of the connection that created the value, and regardless of the scope of the statement that produced the value.
IDENT_CURRENT is not limited by scope and session; it is limited to a specified table. IDENT_CURRENT returns the identity value generated for a specific table in any session and any scope.
To avoid the potential problems associated with adding a trigger later on, always use SCOPE_IDENTITY() to return the identity of the recently added row in your T SQL Statement or Stored Procedure.



@@IDENTITY to retrieve the identity of the most recently added row in a table.  Although this is one of those common practices in SQL Server 7, which does not have a SCOPE_IDENTITY()function, it is no longer the accepted way to get the identity of the most recently added row in a table in SQL Server 2000 and SQL Server 2005.
@@IDENTITY returns the most recently created identity for your current connection, not necessarily the identity for the recently added row in a table.  You could have a situation where there is a trigger that inserts a new record in a Logs Table, for example, when your Stored Procedure or INSERT SQL Statement inserts a record in the Orders Table.  If you use@@IDENTITY to retrieve the identity of the new order, you will actually get the identity of the record added into the Log Table and not the Orders Table, which will create a nasty, nasty bug in your data access layer.
To avoid the potential problems associated with someone adding a trigger later on, always use SCOPE_IDENTITY() to return the identity of the recently added row in your INSERT SQL Statement or Stored Procedure.

Wednesday, July 27, 2011

Bharat Ratna......India's Highest Civilian Award... Politics or Awareness...

Bharat Ratna...... The Republic of India's Highest Civilian Award, awarded for the highest degrees of National Service.
Service includes  Literary, Artistic, Economics and Scientific Achievements.

Strong education system of India, always mentioned (in curriculum text books)  the dignity of this award. Every citizen and student aware of  what this award means.
It's always been a most important General Knowledge question in all level of educational and competitive examinations.

I remember, we used to mug about it with very high respect as a part of our General Knowledge (GK) high school curriculum . The things to remember about, the Recipient Name, Year and the Field to achieve this award.
Time Changes, Things changes,  Generation Changes and within all these natural process of change, India as a Nation changed as well.
Just crossing the puberty age India as a nation gradually kept it's feet in prime age. Yes, India enters into its youth. Every thing drastically changed. India become much more glamorized, wealthier, globalized, going to be mighty global economy.
Among all these add on drastic changing process. It's not important how much Indian foreign policy\politics changed or India's global politics changed but the inter-national politics definitely not changed, little bit.

Political leaders still follow the same old conventional and orthodox way of  politics. Yes, in a name of change in politics we can see some new and highly educated young blood entered. But , that too not by choice but that is just by chance or their luck or their legacy.

Anyways, we're here to discuss the BHARAT RATNA.

The award was established by the first President of India, Dr. Rajendra Prasad, on 2 January 1954.
Till date,  41 awards has been awarded. Out of 41 awards, one is awarded to a naturalised Indian citizen, Mother Teresa (1980), and two Non-Indians, Khan Abdul Ghaffar Khan (1987) and Nelson Mandela (1990).

Here's the list of Bharat Ratna Recipients (in reverse chronical order).

41. Pandit Bhimsen Joshi (2008)
40. Kumari Lata Dinanath Mangeshkar (2001)
39. Ustad Bismillah Khan (2001)
38. Prof. Amartya Sen (1999)
37. Lokpriya Gopinath Bordoloi (1999)
36. Loknayak Jayprakash Narayan (1999)
35. Pandit Ravi Shankar (1999)
34. Shri Chidambaram Subramaniam (1998)
33. Smt. Madurai Shanmukhavadivu Subbulakshmi (1998)
32. Shri (Dr.) Avul Pakir Jainulabdeen Abdul Kalam (1997)
31. Smt. Aruna Asaf Ali (1997)
30. Shri Gulzari Lal Nanda (1997)
29. Shri Jehangir Ratanji Dadabhai Tata (1992)
28. Shri Maulana Abul Kalam Azad (1992)
27. Shri Satyajit Ray (1992)
26. Shri Morarji Ranchhodji Desai (1991)
25. Shri Rajiv Gandhi (1991)
24. Sardar Vallabhbhai Patel (1991)
23. Dr. Bhimrao Ramji Ambedakr (1990)
22. Dr. Nelson Rolihlahla Mandela (1990)
21. Shri Marudur Gopalan Ramachandran (1988)
20. Khan Abdul Ghaffar Khan (1987)
19. Shri Acharya Vinoba Bhave (1983)
18. Mother Teresa (Agnes Gonxha Bojaxhiu) (1980)
17. Shri Kumaraswamy Kamraj (1976)
16. Shri Varahagiri Venkata Giri (1975)
15. Smt. Indira Gandhi (1971)
14. Shri Lal Bahadur Shastri (1966)
13. Dr. Pandurang Vaman Kane (1963)
12. Dr. Zakir Hussain (1963)
11. Dr. Rajendra Prasad (1962)
10. Dr. Bidhan Chandra Roy (1961)
09. Shri Purushottam Das Tandon (1961)
08. Dr. Dhonde Keshav Karve (1958)
07. Pt. Govind Ballabh Pant (1957)
06. Dr. Bhagwan Das (1955)
05. Shri Jawaharlal Nehru (1955)
04. Dr. Mokshagundam Vivesvaraya (1955)
03. Shri Chakravarti Rajagopalachari (1954)
02. Dr. Chandrasekhara Venkata Raman (1954)
01. Dr. Sarvapalli Radhakrishnan (1954)

 The award was briefly suspended from 13 July 1977 to 26 January 1980.
 
So wondering, why did I briefly discuss about politics in between . This highly dignitary award has off and on being political object and being discussed as controversial way.  Like, every highly respected awards (eg, Nobel Prize) , BHARAT RATNA too have some protocols. The Bharat Ratna too is having some guidelines and qualifications.
 
(Apologies,  if any one have the objection)  Most interesting thing about this great award is, some times it discussed and molded as a political object.
 
One of the incident , it was when it's declared for Subhash Chandra Bose in 1992, which was later withdrawn due to a some reasons.  ( read in wiki)
 
Now,  the fun started in April 2011. Occasion was India won the Cricket world Cup.

(I too am,  a great fan of cricket. When one talk about mordern cricket , one cannot disintegrate Sachin Tendulkar from the game. Any person who love the game cricket can't ignore Sachin, the legend. _
 
(The below paragraph is quite hypothetical guys.. just imagining ...) As we know fans are always crazy , some how someone might made some remark about Legendary Sachin that SACHIN is a BHARAT RATNA.....
.......Fine........... Well......Agreed....
Sachin is Bharat Ratna. Not only the whole India but the whole world Love him.
 
 
But indeed,  did anyone try to understand the fact that how intricate would it be to declare Sachin, the  Bharat Ratna?.
Does anyone,  evaluate the technical limitations to declare the award to him.?
I guess, no.. nobody.

The prime technical difficulty is the award is only given in the field of services  Literary, Artistic and Scientific Achievements.
 
Now the politics and poor politicians came into picture, talks started about to amend the guidelines and qualifications of the award.
Can easily  comprehend, Sachin is a big name and utmost popular among nation, entire nation love him. Seeking his popularity and Just to please cricket lovers, Sachin lovers and take the credit that we change and include the sports in the service list of the award, government started the thread.
No political party opposes as after all they need votes, from public.

Astonishingly, they approch towards to change the guidelines and qualification of the Highest Civilian Award.
 
Grow up Govenment....
The True Heros like Sachin does not require any honor like this. Hero like him lives in the heart of billions.

Continuing with the sad political story, Now this hurdle is also seems to be in resolving stage and most of  the political leaders, agreed to include sport on the list. Atleast government proposed BHARAT RATNA for Sachin.

(Reason is obvious, noone want to hurt the emotions of others, some of us realise but hestiate to speak against .)
 
HOLD ON, What's going on ...
Is it fun ... Is politics a power game ....
Can you answer these questions of normal intellectual and educated person of the Nation.

Did you guys change the guidelines when the award  declared to Mr. Bose was withdrawn ?
Is any global Highest Civilian Award included sports?
 
Being commercially successful in any field does make you eligible to deserve the Highest Civilian Award?
What ever rules, guidelines or prototypes had been made for any foundations (either award like this or our constitution) in past, has it's meaning and vision.
It's not like during the initial proposal or establishment of the award, the sport was not there as a part of  society.
Hockey was the most popular sport of that era.

Now some people (hockey lovers) realize, that government already reached  too far to manipulate the service list of BHARAT RATNA. So, they proposed DyanChand, as a sound contester to get BHARAT RATNA. And they are true,  in actual.

No doubt, Sachin is legend of modern cricket , no reasons why shouldn't we praise him with high dignity.
No doubt, he had attended,  all possible heights of success and records. His commitment to nation is superb and appreciable . He has been serving the nation for last 2 decades. His achivements are remarkable and unachieveable. He set up untouchable landmark in the game of cricket.He is most successful persona in all format of game.  He can be addressed as God of cricket, in every way of cricket.
 
Still, I do have couple of questions in my mind.
1. Isn't Sachin too young, to get the honor known as BHARAT RATNA.
2. After so many achivements, does he still comparable with the personalities listed in list of 41 noble personalities, who got the honor.
3. His commitment and dedication is always unquestioned. Can he be rated above Dhyan Chand (hockey player)?
4. If we want to consider Sachin. Can't we put PT Usha and Vishwanathan Anand in the same list?
5. Dont we already have separate award format for sports?

Dont make mockery of the things ...

.Time to think now....
Think before you act ....

Without being political and emotional over the matter, I propose one solution isn't it possible to introduce another award stating equivalent to BHARAT RATNA, in the field of commerical activities (including sports and entertainment industry( or any commerical activities)).
Without touching the existing format of great BHARAT RATNA.

 
 Any suggestions appreciated..............

Date::  11/12/2011.
I wrote this article on July 27 2011. Today I came to know Justice Katju share the same views as I was\am.

http://timesofindia.indiatimes.com/india/Bharat-Ratna-to-cricketers-filmstars-a-mockery-of-award-Justice-Katju/articleshow/11182465.cms

Justice is quite correct , courageous and sane person. May be , thousands of us might be thinking like him or me . But not able to express the views in public.
As Justice is,  in good position to put his thoughts across media so he can express it in public.
Kudos for you Justice Katju.
I'm no-body so I'm writing my views as very common man. I'm sure not body is even going to read it. (:(( ).

Back to topic.  Sure,  mastering in game or cinema is a commitment,  dedication and hardwork . But it;s a God gift too. And surely we should not forget in return of hardwork and dedication, players and movie stars earning a lot of money and their earnings are coming very little or nothing back to society.

Please dont play with the criteria of this highest honaray award; it's very special;  it was especially and intentionally formatted & decidated to highly intellectual individuals. Not like any body.

No offend to anyone. It's just my thoughts which now Justice Katju approved.

 
 
 



Thursday, July 21, 2011

Is Big Players in web sites (like yahoo, TOI, ICICI Bank) thinks Internet Audience, Fool?

Decade 2000-2010 brought new catalyst in the internet websites, thousands of new website being lauched every day throughout the world.
The numbers are multiplying like anything on hourly basis. But , no second thoughts, to the saying "brand is brand". Avid and regular internet users, like me still like to follow the standards and go the regular branded websites.
Each and every website is having it's own regular stream of visitors\users. In technical terms, techies say it users traffic. Every website is having it's own kind of visitor\customer. 

Just think of this way, starting my day in morning,  I visit some regular websites likes gmail, yahoo mail. If I feel like to know, the happening around the world I prefer to visit websites like guardian.co.uk, nytimes. com, timesofindia.com, cnn.com. Since, I visit these websites number of times a day. So,  I provide the regular traffic to these websites.

Similarly, daily I do trading by visiting some trading website. Visit couple of  banking website to check my bank account, for shopping, I visit amazon. Travelling websites, some deals website, some technical websites like MSDN and others and some times google anything random.

So taking me as an example, alone myself providing traffic to hundreds of websites per day and providing thousands of click per hour. For some brands(say 25-30 website) of website I'm regular visitor and for some I'm random visitor.

So here I'm talking about the responsibility of the web site provider to take ownership and take care to it's regular visitors.But unfortunately, some provider completely fail in doing so and I found them completely irresposible in that terms.

I have had a very unpleasant, irritating user experience from the leading website providers. The providers by now become a brand in internet business.

Citing an example of today morning (July 21 2011), going though the yahoo news . One news line-heading, caught my attention and I want to click it, <> it took me to some other international news.

Trying to do:



Result provided by YAHOO



Wondering, taking the responsiblilities, do these companies really test the applications before feeding to customers or for saving the cost they treat customer as their testers.
From last four months yahoo website was crashing when ever you want to go to the photos page in http://www.yahoo/omg/photos
or videos never come up when where you visit the video page.

Yahoo is in the losses, is this the reason to cater this frustrating web pages to visitors OR Yahoo is in losses due to this regular practice. Only YAHOO management knows all about this.

Another example of the most famous website from India news Time Of India. Poor TOI, I do have impression that  they do not have any international standards level  news drafting editorial team for website news. Still I believe and agree it's one of the most popular web news paper.

The problem of these guys is most congested internet advertisement and irregular, periodic advt. popup and sometimes the load music as soon as pop-up windows comes out.
Do TOI guys really have sense for user convenience, is it a fun or what?  Do they take the news editing seriouly in web too. As they (were) serious in print media some decades back.

These web news papers editorial board need to understand the power of web news too. In case of TOI, I simply do not get the need of unusual adversiting. More over,  they are trying to do it when their newz contains are not to the up-international standards. These irritating advt. only putting more bitter topping over the bitter catered cake (of newz contents).

Another example of the website like ICICI bank. ICICI bank suppose to be latest bank in India. I'm not aware about it popularity, globally. Quite slow website, you'll find the website down, sporadically. Do you expect a second largest bank website could be too slow to log-in and can get down anytime. Anytime you might be in-need to use it urgently. ( though, now I heard they are working over it. )

In the case of ICICI's money2India website, One of the most tragic activity they did. In process to renovate the website they remove (rarely used) or less used account and the customer who were not so frequent. I donot know how valid is it?
Can any large bank afford to have the irregular website, moreover when you have paralysed customer service.

Surprising, astonishing but true. No doubt,  the above cited are big companies and having lot of customers around. Is it because they are old companies, they are getting advantage of  population (in India). I rate them irresposible, do you? I think these companies have yet to understand the power and potential of web based internet platform.
Some one responsible from these companies management has to answer it ? They should learn the visitor experience . They should understand this new era of customers.

Any comment appreciated.......






Tuesday, July 19, 2011

_mbsspnp, _strspnp, _wcsspnp, _tcsspnp

unsigned char *_mbsspnp( const unsigned char *string1,   const unsigned char *string2 );

Routine Required Header Compatibility
_mbsspnp Win 95, Win NT
_strspnp Win 95, Win NT
_wcsspnp Win 95, Win NT

Libraries
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value:
_strspnp, _wcsspnp, and _mbsspnp return a pointer to the first character in string1 that does not belong to the set of characters in string2. Each of these functions returns NULL if string1 consists entirely of characters from string2. For each of these routines, no return value is reserved to indicate an error.

Parameters
string1 : Null-terminated string to search
string2 :   Null-terminated character set

Remarks:
The _mbsspnp function returns a pointer to the multibyte character that is the first character in string1 that does not belong to the set of characters in string2. _mbsspnp recognizes multibyte-character sequences according to the multibyte code page currently in use. The search does not include terminating null characters.

The generic-text function _tcsspnp, defined in TCHAR.H, maps to _mbsspnp if _MBCS has been defined, or to _wcsspnp if _UNICODE has been defined. Otherwise _tcsspnp maps to _strspnp. _strspnp and _wcsspnp are single-byte character and wide-character versions of _mbsspnp. _strspnp and _wcsspnp behave identically to _mbsspnp otherwise; they are provided only for this mapping and should not be used for any other reason. For more information, see Using Generic-Text Mappings and Appendix B, Generic-Text Mappings.

MSDN Example:
/* STRSPN.C: This program uses strspn to determine  the length of the segment in the string "cabbage"
* consisting of a's, b's, and c's. In other words,  it finds the first non-abc letter.*/

#include
#include
void main( void )
{
   char string[] = "cabbage";
   int result;
   result = strspn( string, "abc" );
   printf( "The portion of '%s' containing only a, b, or c "  "is %d bytes long\n", string, result );
}

Output:  The portion of 'cabbage' containing only a, b, or c is 5 bytes long

See my Example , that will give you clear picture and understanding:
Sample code from my project:
void CUnicodeCharDlg::OnBnClickedButton2()

{
   CString csData;
   m_edit2.GetWindowText(csData);
   UpdateData(TRUE);
   static TCHAR * lpszValidChars = _T("ABCDEFGHIJKLMNOPQRSTUVWXYZ");

    // szText is the string you wanna check for invalid chracters
    if     (_tcsspnp(csData, lpszValidChars) != 0)
         {   MessageBox("Invalid Input Characters!", "Error", 0); }

         else {  MessageBox("Thats Correct Input!", "Great", 0); }
}

Exploring CEdit VC++\MFC

CEdit Class

Provides the functionality of a Windows edit control.

class CEdit : public CWnd


Details:
An edit control is a rectangular child window in which the user can enter text.

You can create an edit control either from a dialog template or directly in your code. In both cases, first call the constructor CEdit to construct the CEdit object, then call the Create member function to create the Windows edit control and attach it to the CEdit object.

Construction can be a one-step process in a class derived from CEdit. Write a constructor for the derived class and call Create from within the constructor.

CEdit inherits significant functionality from CWnd. To set and retrieve text from a CEdit object, use the CWnd member functions SetWindowText and GetWindowText, which set or get the entire contents of an edit control, even if it is a multiline control. Text lines in a multiline control are separated by '\r\n' character sequences. Also, if an edit control is multiline, get and set part of the control's text by calling the CEdit member functions GetLine, SetSel, GetSel, and ReplaceSel.

If you want to handle Windows notification messages sent by an edit control to its parent (usually a class derived from CDialog), add a message-map entry and message-handler member function to the parent class for each message.

Each message-map entry takes the following form:
ON_Notification( id, memberFxn )
where id specifies the child window ID of the edit control sending the notification, and memberFxn is the name of the parent member function you have written to handle the notification.

The parent's function prototype is as follows:
afx_msg void memberFxn( );

Following is a list of potential message-map entries and a description of the cases in which they would be sent to the parent:

ON_EN_CHANGE The user has taken an action that may have altered text in an edit control. Unlike the EN_UPDATE notification message, this notification message is sent after Windows updates the display.
ON_EN_ERRSPACE The edit control cannot allocate enough memory to meet a specific request.
ON_EN_HSCROLL The user clicks an edit control's horizontal scroll bar. The parent window is notified before the screen is updated.
ON_EN_KILLFOCUS The edit control loses the input focus.
ON_EN_MAXTEXT The current insertion has exceeded the specified number of characters for the edit control and has been truncated. Also sent when an edit control does not have the ES_AUTOHSCROLL style and the number of characters to be inserted would exceed the width of the edit control. Also sent when an edit control does not have the ES_AUTOVSCROLL style and the total number of lines resulting from a text insertion would exceed the height of the edit control.

ON_EN_SETFOCUS Sent when an edit control receives the input focus.
ON_EN_UPDATE The edit control is about to display altered text. Sent after the control has formatted the text but before it screens the text so that the window size can be altered, if necessary.

ON_EN_VSCROLL The user clicks an edit control's vertical scroll bar. The parent window is notified before the screen is updated.
If you create a CEdit object within a dialog box, the CEdit object is automatically destroyed when the user closes the dialog box.

If you create a CEdit object from a dialog resource using the dialog editor, the CEdit object is automatically destroyed when the user closes the dialog box.

If you create a CEdit object within a window, you may also need to destroy it. If you create the CEdit object on the stack, it is destroyed automatically. If you create the CEdit object on the heap by using the new function, you must call delete on the object to destroy it when the user terminates the Windows edit control. If you allocate any memory in the CEdit object, override the CEdit destructor to dispose of the allocations.

CEdit::GetSel 
Call this function to get the starting and ending character positions of the current selection (if any) in an edit control, using either the return value or the parameters.

DWORD GetSel( ) const;

void GetSel(  int& nStartChar,  int& nEndChar ) const;

Parameters:
nStartChar :  Reference to an integer that will receive the position of the first character in the current selection.

nEndChar : Reference to an integer that will receive the position of the first nonselected character past the end of the current selection.

Return Value
The version that returns a DWORD returns a value that contains the starting position in the low-order word and the position of the first nonselected character after the end of the selection in the high-order word.

// The pointer to edit box.

CEdit* pEdit;
// Set the selection to be all characters after the current selection.
DWORD dwSel = pmyEdit->GetSel();
pmyEdit->SetSel(HIWORD(dwSel), -1);

CEdit::SetSel
Call this function to select a range of characters in an edit control.
In two Different ways:

i)   void SetSel( DWORD dwSelection, BOOL bNoScroll = FALSE );
ii)  void SetSel( int nStartChar,  int nEndChar,  BOOL bNoScroll = FALSE );

Parameters: dwSelection
Specifies the starting position in the low-order word and the ending position in the high-order word. If the low-order word is 0 and the high-order word is –1, all the text in the edit control is selected. If the low-order word is –1, any current selection is removed.

bNoScroll
Indicates whether the caret should be scrolled into view. If FALSE, the caret is scrolled into view. If TRUE, the caret is not scrolled into view.

nStartChar
Specifies the starting position. If nStartChar is 0 and nEndChar is –1, all the text in the edit control is selected. If nStartChar is –1, any current selection is removed.

nEndChar
Specifies the ending position.

Example: Ref. above.


Problems and Solutions in CEdit class
Problem 1: I'm tring to set the focus to an edit box with GetDlgItem(IDC_FIRSTNAME)->SetFocus();

then i tried to to select its content with SetSel().  but somehow it does not work.

I Tried this way:
(IDC_EDIT)->SetSel();
IDC_EDIT.SetSel();
m_Edit.SetSel();

Getting compiler Error saying:   "the left part of .SetSel has to be a class/struct/union."  or   "SetSel is no element of CWnd"
how is it correct?

Solution:
You are trying to implement it in a wrong way.
Try to understand here :
GetDlgItem  returns the Adress of your dialog item, but here the dataType is CWnd*


CWnd - is a parent class of all controls - doesn't have a method "SetSel()". This method is declared and defined in the class CEdit, which of course is a child class of CWnd.


Making a call  CWnd* (as you get it from GetDlgItem()) with the "->" operator, the pointer is dereferenced as CWnd.

So all you have to do is to cast the pointer to CEdit*, to to this change your line of code to

CEdit *pYourEdit = (CEdit*) GetDlgItem(IDC_FIRSTNAME);
pYourEdit ->SetSel(0, -1);

Or  use,      ( (CEdit*) GetDlgItem(IDC_FIRSTNAME) )->SetSel(0, -1);

Another way of calling the functions, You can also use , the functions this way.
m_CtlEdit.SetFocus()
m_CtlEdit.SetSel(5,7)


Here is an another sample code:

void CYourDlg::OnButton()
{
   UpdateData(TRUE);
   GetDlgItem(IDC_FIRSTNAME)->SetFocus();
   GetDlgItem(IDC_FIRSTNAME)->SetSel(0, -1);
   UpdateData(FALSE);

}

Health Benefits of Cashews

  Benefits of Cashews. Healthy food is an integral part of healthy body. Regular exercises such as Yoga and healthy diet is important to...