This method is created in a ClassLibrary file,that i will use it in my main project.From main project this validation() method will be called to check whether the string 'str' passed is of specified type as in the database table's particular field.
So,how to get the datatype of a field of a particular table in a particular database?

hi,
In my own defined method ,i will pass the connection string of the database and table name in the parameter.
And my method should return the number of columns and datatype of each column in the table.
That how to do?

You can execute the stored procedure sp_help with the tablename to get a resultset with the column names, data type and other extra info. You can use this resultset to extract the necessary colulmn name and data type information.