Click here to Skip to main content
15,909,945 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute17-Dec-10 14:56
Henry Minute17-Dec-10 14:56 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC17-Dec-10 15:11
LAPEC17-Dec-10 15:11 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC18-Dec-10 12:28
LAPEC18-Dec-10 12:28 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute18-Dec-10 13:13
Henry Minute18-Dec-10 13:13 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC18-Dec-10 13:25
LAPEC18-Dec-10 13:25 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute19-Dec-10 0:35
Henry Minute19-Dec-10 0:35 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC19-Dec-10 1:15
LAPEC19-Dec-10 1:15 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute19-Dec-10 1:41
Henry Minute19-Dec-10 1:41 
Good!

Once again if I am correct in assuming that what you are designing will not be used for entering data into the main tables but simply for taking orders or similar functions.

You can keep the DataSet and DataTable structure I used in my example. All that needs to change are the Sql SELECT statements, like this:

C#
string starterSql = @"SELECT * FROM Food WHERE Food_Type = 'Starter'";
string mainSql = @"SELECT * FROM Food WHERE Food_Type = 'Main'";
// add a statement for each of Dessert, Side Order etc.


using (SqlConnection conn = new SqlConnection(connString))
{
    try
    {
        conn.Open();
        SqlDataAdapter starterDa = new SqlDataAdapter(starterSql, conn);
        starterDa.Fill(menuDS, "Starter");
        SqlDataAdapter mainDa = new SqlDataAdapter(mainSql, conn);
        mainDa.Fill(menuDS, "Main");
        SqlDataAdapter dessertDa = new SqlDataAdapter(dessertSql, conn);
        dessertDa.Fill(menuDS, "Dessert");
        // repeat as necessary

        starterTable = menuDS.Tables["Starter"];
        mainTable = menuDS.Tables["Main"];
        dessertTable = menuDS.Tables["Dessert"];
        // repeat
    }
    catch (Exception e)
    {
        Console.WriteLine("Error: " + e);
    }
}


One thing I will say is that you should not press ahead with designing all your user controls just yet. For now just have, maybe, two for testing purposes. The reason for this is that in reality you will not know what buttons will be required until run-time and the buttons will therefore need to be created and added dynamically depending on what items are in the Food database at that time. These things change, some items are dropped and others added. So what should happen is that there should only be one UserControl exactly the same as the one in my example but without the Buttons. When needed, a new one should be created by adding the buttons and hooking them up to the ItemSelected Event.

When you are ready for that I will help you, if you need it.

Good luck. Smile | :)
Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”

GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC19-Dec-10 1:57
LAPEC19-Dec-10 1:57 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute19-Dec-10 2:01
Henry Minute19-Dec-10 2:01 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC19-Dec-10 6:09
LAPEC19-Dec-10 6:09 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute19-Dec-10 9:41
Henry Minute19-Dec-10 9:41 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC19-Dec-10 10:16
LAPEC19-Dec-10 10:16 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC21-Dec-10 1:23
LAPEC21-Dec-10 1:23 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute21-Dec-10 3:01
Henry Minute21-Dec-10 3:01 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute21-Dec-10 3:09
Henry Minute21-Dec-10 3:09 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC21-Dec-10 13:06
LAPEC21-Dec-10 13:06 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute21-Dec-10 13:21
Henry Minute21-Dec-10 13:21 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC21-Dec-10 13:33
LAPEC21-Dec-10 13:33 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute21-Dec-10 13:34
Henry Minute21-Dec-10 13:34 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC21-Dec-10 13:35
LAPEC21-Dec-10 13:35 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC21-Dec-10 13:55
LAPEC21-Dec-10 13:55 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute21-Dec-10 14:13
Henry Minute21-Dec-10 14:13 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC21-Dec-10 14:43
LAPEC21-Dec-10 14:43 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute21-Dec-10 14:50
Henry Minute21-Dec-10 14:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.