Formula una domandaFormula una domanda
 

Con rispostaGridView

Risposte

Tutte le risposte

  • mercoledì 4 novembre 2009 20.01qasemt Medaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     

    hi...

    web application Datagrid

    // Setup DB-Connection
                ConnectionString = "data source=xeon;uid=sa;password=manager;database=northwind";
                SqlConnection cn = new SqlConnection(ConnectionString);

                // Create the DataSet
                ds = new DataSet("CustOrders");

                // Fill the Dataset with Customers, map Default Tablename
                // "Table" to "Customers".

                SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Customers",cn);
                da1.TableMappings.Add("Table","Customers");
                da1.Fill(ds);

     // Grid Databinding
                grdOrders.DataSource =
    ds.DefaultViewManager ;

                grdOrders.DataBind();

     


    Data Binding in .NET / C# Windows Forms

    // Setup DB-Connection
                ConnectionString = "data source=xeon;uid=sa;password=manager;database=northwind";
                SqlConnection cn = new SqlConnection(ConnectionString);

                // Create the DataSet
                ds = new DataSet("CustOrders");

                // Fill the Dataset with Customers, map Default Tablename
                // "Table" to "Customers".

                SqlDataAdapter da1 = new SqlDataAdapter("SELECT * FROM Customers",cn);
                da1.TableMappings.Add("Table","Customers");
                da1.Fill(ds);

     // Grid Databinding
                grdOrders.DataSource =
    ds.DefaultViewManager ;

  • martedì 10 novembre 2009 7.29Harry ZhuMSFT, ModeratoreMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utenteMedaglie utente
     Con risposta
    Hi,

    You might be more specific about the question.
    Do you mean DataGridView control?

    What database do you want to connect to?

    we can first retrieve the data into a dataset then bind it to datagridview.
    Please take a look at the article about how to bind data to the windows forms DataGridView: http://msdn.microsoft.com/en-us/library/fbk67b6z.aspx

    Harry

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.