Hi. im developing a loan processing system using mvc c# asp.net.
One of the requirements of the system is to perform a credit history check on the customer applying for a loan.

so this is how it works:
-the customer applies for a loan. the customers id number gets stored in the id document table in the database.
-since we can't automate the credit history heck process, the information is sent to an excl file so the employee then enters the customer's ID number in the system they have to do the necessary check.
-so the employee clicks on the option "credit check" which will populate a view with all the customer's whose credit check status is "Pending".

in my business logic i have the following method to transfer the data into an excel file

    public DataTable GetForCreditCheck()
    {
        using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString))
        using (var cmd = new SqlCommand("SELECT * FROM IdentityDocuments", conn))
        using (var adapter = new SqlDataAdapter(cmd))
        {
            var idDocuments = new DataTable();
            adapter.Fill(idDocuments);
            return idDocuments;
        }
    }

look at "using (var cmd = new SqlCommand("SELECT * FROM IdentityDocuments", conn))".
Instead of saying "SELECT * FROM IdentityDocuments" i just want to select the ID number field ... what's the sql syntax for that?

SELECT ID FROM IdentityDocuments

Thank you

and what if i want to submit more than 1 field, eg customer name, surname, and id number?

Hi,

I think these links will help you on how to use a select statement: msdn, w3schools

SELECT Column1, Column2, Column3...
From     [table name goes here]
WHERE [condition goes here for filtering result "if wished"]

Try not to use SELECT * FROM [table name] as it is not a performance wise. Try to specifiy the columns as possible as you can. The execution steps followed by the db engine is as follows:
1- FROM [table]
2- WHERE [condition]
3- GROUP BY [group]
4- HAVING [condition on grouping basis]
5- SELECT [columns]
6 ORDER BY [columns to order result by] [ASC|DESC]

Please try this query :

select column1,column2 from table_name
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.