0

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?

1
Contributor
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Duki
0

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?

Edited by Duki: n/a

0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.