Click here to Skip to main content
15,906,106 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Does garbage collection in .Net multithreaded nowadays? Pin
Kevin McFarlane16-Sep-08 8:49
Kevin McFarlane16-Sep-08 8:49 
GeneralRe: Does garbage collection in .Net multithreaded nowadays? Pin
followait17-Sep-08 17:47
followait17-Sep-08 17:47 
GeneralRe: Does garbage collection in .Net multithreaded nowadays? Pin
Dave Kreskowiak19-Sep-08 7:57
mveDave Kreskowiak19-Sep-08 7:57 
RantApp_Code problem Pin
Richard Jones15-Sep-08 3:35
Richard Jones15-Sep-08 3:35 
GeneralRe: App_Code problem Pin
Steven A. Lowe16-Sep-08 15:45
Steven A. Lowe16-Sep-08 15:45 
QuestionFilling a DataGridView containing a ComboBox Pin
akhi4akhil14-Sep-08 19:37
akhi4akhil14-Sep-08 19:37 
AnswerRe: Filling a DataGridView containing a ComboBox Pin
srabik15-Sep-08 2:48
srabik15-Sep-08 2:48 
GeneralRe: Filling a DataGridView containing a ComboBox Pin
srabik15-Sep-08 3:13
srabik15-Sep-08 3:13 
Hmm, that seems not to work too..

Last thing, code from VS Help:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

public class Form1 : System.Windows.Forms.Form
{
    private DataGridView dataGridView1 = new DataGridView();
    private BindingSource bindingSource1 = new BindingSource();
    private SqlDataAdapter dataAdapter = new SqlDataAdapter();
    private Button reloadButton = new Button();
    private Button submitButton = new Button();

    [STAThreadAttribute()]
    public static void Main()
    {
        Application.Run(new Form1());
    }

    // Initialize the form.
    public Form1()
    {
        dataGridView1.Dock = DockStyle.Fill;

        reloadButton.Text = "reload";
        submitButton.Text = "submit";
        reloadButton.Click += new System.EventHandler(reloadButton_Click);
        submitButton.Click += new System.EventHandler(submitButton_Click);

        FlowLayoutPanel panel = new FlowLayoutPanel();
        panel.Dock = DockStyle.Top;
        panel.AutoSize = true;
        panel.Controls.AddRange(new Control[] { reloadButton, submitButton });

        this.Controls.AddRange(new Control[] { dataGridView1, panel });
        this.Load += new System.EventHandler(Form1_Load);
        this.Text = "DataGridView databinding and updating demo";
    }

    private void Form1_Load(object sender, System.EventArgs e)
    {
        // Bind the DataGridView to the BindingSource
        // and load the data from the database.
        dataGridView1.DataSource = bindingSource1;
        GetData("select * from Customers");
    }

    private void reloadButton_Click(object sender, System.EventArgs e)
    {
        // Reload the data from the database.
        GetData(dataAdapter.SelectCommand.CommandText);
    }

    private void submitButton_Click(object sender, System.EventArgs e)
    {
        // Update the database with the user's changes.
        dataAdapter.Update((DataTable)bindingSource1.DataSource);
    }

    private void GetData(string selectCommand)
    {
        try
        {
            // Specify a connection string. Replace the given value with a 
            // valid connection string for a Northwind SQL Server sample
            // database accessible to your system.
            String connectionString =
                "Integrated Security=SSPI;Persist Security Info=False;" +
                "Initial Catalog=Northwind;Data Source=localhost";

            // Create a new data adapter based on the specified query.
            dataAdapter = new SqlDataAdapter(selectCommand, connectionString);

            // Create a command builder to generate SQL update, insert, and
            // delete commands based on selectCommand. These are used to
            // update the database.
            SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

            // Populate a new data table and bind it to the BindingSource.
            DataTable table = new DataTable();
            table.Locale = System.Globalization.CultureInfo.InvariantCulture;
            dataAdapter.Fill(table);
            bindingSource1.DataSource = table;

            // Resize the DataGridView columns to fit the newly loaded content.
            dataGridView1.AutoResizeColumns( 
                DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
        }
        catch (SqlException)
        {
            MessageBox.Show("To run this example, replace the value of the " +
                "connectionString variable with a connection string that is " +
                "valid for your system.");
        }
    }

}

GeneralRe: Filling a DataGridView containing a ComboBox Pin
akhi4akhil16-Sep-08 0:22
akhi4akhil16-Sep-08 0:22 
GeneralRe: Filling a DataGridView containing a ComboBox Pin
akhi4akhil16-Sep-08 1:25
akhi4akhil16-Sep-08 1:25 
GeneralRe: Filling a DataGridView containing a ComboBox Pin
akhi4akhil16-Sep-08 0:04
akhi4akhil16-Sep-08 0:04 
GeneralRe: Filling a DataGridView containing a ComboBox Pin
srabik16-Sep-08 2:57
srabik16-Sep-08 2:57 
GeneralRe: Filling a DataGridView containing a ComboBox Pin
akhi4akhil16-Sep-08 17:14
akhi4akhil16-Sep-08 17:14 
GeneralRe: Filling a DataGridView containing a ComboBox Pin
akhi4akhil16-Sep-08 0:19
akhi4akhil16-Sep-08 0:19 
QuestionClickOnce Deployment - force download file with different version but same hash Pin
srabik14-Sep-08 13:32
srabik14-Sep-08 13:32 
QuestionBorder+ColorAnimation (Borderbrush) Pin
Stevie14-Sep-08 8:25
Stevie14-Sep-08 8:25 
AnswerRe: Border+ColorAnimation (Borderbrush) Pin
Stevie14-Sep-08 8:35
Stevie14-Sep-08 8:35 
QuestionForm crashes to taskbar when left minimized? [modified] Pin
teddycrew12-Sep-08 0:23
teddycrew12-Sep-08 0:23 
AnswerRe: Form crashes to taskbar? Pin
led mike12-Sep-08 5:02
led mike12-Sep-08 5:02 
GeneralRe: Form crashes to taskbar? Pin
teddycrew12-Sep-08 12:58
teddycrew12-Sep-08 12:58 
Questioninstallation issue of dot net 2005 Pin
onrivman11-Sep-08 21:19
onrivman11-Sep-08 21:19 
AnswerRe: installation issue of dot net 2005 Pin
Pete O'Hanlon11-Sep-08 22:11
mvePete O'Hanlon11-Sep-08 22:11 
GeneralHelp required in SQL query Pin
khalidd11-Sep-08 0:06
khalidd11-Sep-08 0:06 
GeneralRe: Help required in SQL query Pin
Pete O'Hanlon11-Sep-08 0:55
mvePete O'Hanlon11-Sep-08 0:55 
GeneralRe: Help required in SQL query Pin
Paul Conrad11-Sep-08 6:30
professionalPaul Conrad11-Sep-08 6:30 

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.