+ 1
¿Como agregar varios productos a un pedido desde un GridView y registrarlos en Sql Server?
Buenas noches, estoy desarrollando un proyecto en C#, en este debo agregar varios productos a un pedido, estoy intentado por medio de un GridView, pero no tengo idea de como llevarlo acabo... Alguien que conozca la respuesta y me pueda ayudar? Gracias!!
3 Respostas
+ 1
Thank you!! 👍
0
?
0
A gridview is a windows control which is part of the UI.
A database is something you want to have in the background but it is something only code should write data in so seperated those layers.
You make a connection to the database using a sql connection.
You fill a dataadapter with the data from the database
You show the data in the dataadapter in the gridview
using datasource.
https://www.dotnetperls.com/datagridview-tutorial
            using (SqlCeConnection c = new SqlCeConnection(
                Properties.Settings.Default.DataConnectionString))
            {
                c.Open();
                // 2
                // Create new DataAdapter
                using (SqlCeDataAdapter a = new SqlCeDataAdapter(
                    "SELECT * FROM Animals", c))
                {
                    // 3
                    // Use DataAdapter to fill DataTable
                    DataTable t = new DataTable();
                    a.Fill(t);
                    // 4
                    // Render data onto the screen
                    dataGridView1.DataSource = t;



