I have a datagrid showing my items - I want to modify a field in the database when the user clicks a button. So if row 3 is selected, I want to modify "SomeField" in Row3 to True. Is there an easy way to accomplish that?

Is the only way to do this through sql connections? I've started a bit of code, but I have no idea if what I'm doing is correct... I'm getting compile errors so I'm apparently misunderstanding something.

public main_Form()
        {
            InitializeComponent();
            ADODB.Connection cn = new ADODB.Connection();
            ADODB.Recordset rs = new ADODB.Recordset();
            string cnStr;
            string query;

            //Connection string.
            cnStr = "Data Source=REG-PENTREE1//SQLEXPRESS;Initial Catalog=reg_assetcheckout;User ID=user;Password=pw";
            cn.Open(cnStr, null, null, 0);


        }

Is there an easier, maybe built-in way to do database updating?

Ok, I know I'm kind of talking to myself here - but just in case, here's what I have so far. I did away with the code above and am instead doing this:

private void button_Checkout_Click(object sender, EventArgs e)
        {
            DataGridViewRow row = dataGridView1.SelectedRows[0];
            MessageBox.Show(Convert.ToString((row.Cells[0].Value)));
            row.Cells[0].Value = "Pen-Laptop3";
....

This will change the database entry in my application, but it doesn't actually write it to the database. Any ideas?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.