Click here to Skip to main content
15,918,193 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute9-Jan-11 8:38
Henry Minute9-Jan-11 8:38 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC9-Jan-11 8:41
LAPEC9-Jan-11 8:41 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute9-Jan-11 9:10
Henry Minute9-Jan-11 9:10 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC30-Jan-11 4:13
LAPEC30-Jan-11 4:13 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
Henry Minute10-Feb-11 13:20
Henry Minute10-Feb-11 13:20 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC10-Feb-11 13:41
LAPEC10-Feb-11 13:41 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC10-Feb-11 13:57
LAPEC10-Feb-11 13:57 
GeneralRe: C# - How to call database records one-by-one and display it in ListView? Pin
LAPEC9-Jan-11 8:52
LAPEC9-Jan-11 8:52 
you know the datagridview I have the one with qty in stock and status,
how can populate this two columns with data? Is ther a loop to use or something else...

This is what datagridview looks when I click the starter button

===============================================================
FoodName        FoodType     Qty In Stock     Status
===============================================================
Olives          Starter                     
Soup            Starter                     
Caprese	        Starter
Bruschetta	Starter
Mushroom	Starter
Antipasto	Starter
Scallops	Starter
Calamari	Starter
Crab Avocado	Starter
Pizza Bread	Starter
===============================================================


And this is what datagridview should look like when when generating the other to column template...

=================================================================
FoodName        FoodType     Qty In Stock     Status
=================================================================
Olives          Starter      0                Allways On Stock
Soup            Starter      0                Allways On Stock
Caprese	        Starter      0                Allways On Stock
Bruschetta	Starter      0                Allways On Stock
Mushroom	Starter      0                Allways On Stock
Antipasto	Starter      0                Allways On Stock
Scallops	Starter      0                Allways On Stock
Calamari	Starter      0                Allways On Stock
Crab Avocado	Starter      0                Allways On Stock
Pizza Bread	Starter      0                Allways On Stock
=================================================================


here is the code of cmdStarter_Click even button....

private DataGridViewTextBoxColumn ColFoodQtyStock = new DataGridViewTextBoxColumn();
        private DataGridViewTextBoxColumn ColFoodStatus = new DataGridViewTextBoxColumn();

        private void cmdStarters_Click(object sender, EventArgs e)
        {
            OleDbConnectionStringBuilder connBuilder = new OleDbConnectionStringBuilder();
            connBuilder.DataSource = @"C:\Users\AP_AE\Desktop\DTPOS_APP\DataBase\DtposMenu.accdb";
            connBuilder.Provider = "Microsoft.ACE.OLEDB.12.0";
            connBuilder.Add("Jet OLEDB:Engine Type", "5");

            // Food SQL Query
            string foodTypeSql = @"SELECT FoodName, FoodType FROM Food WHERE FoodType = @foodType";
            using (OleDbConnection conn = new OleDbConnection(connBuilder.ConnectionString))
            {
                dataGridView1.Columns.Clear();
                dataGridView1.RowTemplate.Height = 60;
                //====================================\\
                dataGridView1.Visible = true;
                dataGridView2.Visible = false;
                try
                {
                    OleDbCommand foodsCommand = new OleDbCommand(foodTypeSql, conn);
                    OleDbParameter foodType = foodsCommand.Parameters.Add("@foodType", OleDbType.VarChar, 15);
                    OleDbDataAdapter foodsDa = new OleDbDataAdapter(foodsCommand);
                    //DataRow dr;
                    DataSet ds = new DataSet();
                    conn.Open();
                    foodType.Value = "Starter";
                    foodsDa.Fill(ds, "Food_table");
                    
                    //conn.Close();
                    dataGridView1.DataSource = ds;
                    dataGridView1.DataMember = "Food_table";

                    dataGridView1.Columns.AddRange(ColFoodQtyStock, ColFoodStatus);
                    
                    DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
                    this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
                    dataGridViewCellStyle1.Font = new Font("Verdana", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));

                    this.dataGridView1.Columns[0].Width = 420;
                    this.dataGridView1.Columns[1].Width = 180;
                    this.dataGridView1.Columns[2].Width = 300;
                    this.dataGridView1.Columns[3].Width = 308;

                    // ColStatus 
                    ColFoodStatus.HeaderText = "Status";
                    ColFoodStatus.Name = "ColFoodStatus";

                    // ColQtyStock
                    ColFoodQtyStock.HeaderText = "Quantity In Stock";
                    ColFoodQtyStock.Name = "ColFoodQtyStock";
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex);
                }
            }
        }

QuestionHelp with UAC Issue Pin
Jammer16-Dec-10 8:15
Jammer16-Dec-10 8:15 
AnswerRe: Help with UAC Issue Pin
Jammer17-Dec-10 9:39
Jammer17-Dec-10 9:39 
Questionset url file Pin
ali_heidari_16-Dec-10 3:24
ali_heidari_16-Dec-10 3:24 
AnswerRe: set url file Pin
Hari Om Prakash Sharma16-Dec-10 3:53
Hari Om Prakash Sharma16-Dec-10 3:53 
QuestionI am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Honeyboy_2016-Dec-10 2:56
Honeyboy_2016-Dec-10 2:56 
AnswerRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Thomas Krojer16-Dec-10 3:03
Thomas Krojer16-Dec-10 3:03 
AnswerRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Hari Om Prakash Sharma16-Dec-10 3:19
Hari Om Prakash Sharma16-Dec-10 3:19 
AnswerRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? [modified] Pin
Hari Om Prakash Sharma16-Dec-10 3:36
Hari Om Prakash Sharma16-Dec-10 3:36 
GeneralRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Luc Pattyn16-Dec-10 4:17
sitebuilderLuc Pattyn16-Dec-10 4:17 
GeneralRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Hari Om Prakash Sharma16-Dec-10 4:29
Hari Om Prakash Sharma16-Dec-10 4:29 
AnswerRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Luc Pattyn16-Dec-10 5:13
sitebuilderLuc Pattyn16-Dec-10 5:13 
GeneralRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Hari Om Prakash Sharma16-Dec-10 5:16
Hari Om Prakash Sharma16-Dec-10 5:16 
GeneralRe: I am read File and I want to get information from each 256 byte and from each 256 byte ? Pin
Vern Ma16-Dec-10 16:12
Vern Ma16-Dec-10 16:12 
QuestionCrystal Reports Page Header Problem Pin
Muneeb Abdul Shakoor16-Dec-10 2:42
Muneeb Abdul Shakoor16-Dec-10 2:42 
AnswerRe: Crystal Reports Page Header Problem Pin
FunkySteve16-Dec-10 2:49
FunkySteve16-Dec-10 2:49 
GeneralRe: Crystal Reports Page Header Problem Pin
Muneeb Abdul Shakoor16-Dec-10 3:03
Muneeb Abdul Shakoor16-Dec-10 3:03 
QuestionWeb browser in asp.net Pin
abbd16-Dec-10 0:07
abbd16-Dec-10 0:07 

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.