Start learning C # today #. The reason was said in the complaint just now. Don't repeat it, so that you don't have to change your mother-in-law.
My learning method is work. The so-called work is to make things. This time I am working on a simple source code manager. Note: My notebook only records some C # syntaxes and some things that make me find answers for a long time. With regard to programming thinking, you can leave it as a waste of garbage.
The platform is vWD 2005 bate .. Net Framework 2.0 (Source:. NET Framework SDK documentation ).
Today I am logging in and have encountered the following problems.
I. database:
Oledbcommand. executescalar ()-> SDK indicates the first column in the first row of the result set. Return type: Object
I used this to verify the account password. The trouble is that, due to ASP, it is possible to use is null to check whether data is returned. After a long time. C # determines that null is determined directly by object = NULL.
Gains:
1) the null Judgment Method of C # is object = NULL.
2) When oledbcommand. executescalar () does not return NULL, it can be converted to int. The value is 1.
3) string m_strdata = (string) the object can be converted to a string in a strong way. If it cannot be forcibly converted to a string, an error occurs.
Ii. Custom class:
My first class is the database link class. In fact, I close the functions and two common functions from the commonly used database links in ASP. I don't know if it's useless, but I already wrote it.
Problem 1: mappath
This method is common and frequently used. However, an error occurs when I reference a namespace in the CS file. After several hours of tossing, I was instructed to use httpcontext. Current. server. mappate.
Tip 2: How can an object accept values of any data type? It can be used when you cannot confirm the Data Type of a field. I am using my two SQL Injection defense functions. Intsql (Object a_intvalue) and strsql (Object a_strvalue, int a_intmaxlen ). Intsql checks whether there are non-numeric characters in a_intvalue, and returns 0 if any. The data type is string. Because it must be an SQL statement. Strsql converts a single quotation mark in a_strvalue into two. Then add a single quotation mark to the front and back. If a_strvalue.length exceeds a_intmaxlen, a_strvalue = a_strvalue.substring (0, a_intmaxlen ).
Harvest 3: One of the most idiotic gains. It is the class placed in the app_code directory. It can be directly instantiated using new in the whole site's C # code. You do not need to use using for reference. I also spent more than an hour trying to solve this problem. I found that the error was due to the fact that () was not added after the class name during the new instantiation. There are tired people.
It's really tiring to explore it yourself. Sometimes it takes a lot of time for some very idiotic questions. Because the question is too idiotic, there is no place to find the answer. Really depressing. Therefore, write out all the troubles you have encountered, so that those who have the same headache for these small problems do not have to be so troublesome.
Here, I would like to thank all the people who have helped me in the group. It is estimated that I am still suffering from these troubles. Thank you.