Hey

I have attached my program to the thread.

I have an access database called "Database". I have 3 textboxes. "name" "age" and "language" as an example.

When the accept button is clicked, i want that information to update to the database.

I can only do it with a datagridview, but now i want to do it without, as there is no need for it.

Thank you
Rua

Recommended Answers

All 2 Replies

Yes you can do it without gridview.. you just need to write a Updatae query to update the data in database..

your code looks like below..

OleDbCommand objCmd = new OleDbCommand();
objCmd.Connection = objCon;
objCmd.CommandText = "Update yourtablename Set col1=@col1, col2=@col2 Where idcolum=@idcol";
objCmd.Parameters.AddWithValue("@col1", txtnam.Text);
objCmd.Parameters.AddWithValue("@col2", txtnam.Text);
objCmd.Parameters.AddWithValue("@idcol", txtID.Text);
objCon.Open();
objCmd.ExecuteNonQuery();
objCon.Close();

that's all.. try by above code and let me know...

Hey

I have attached my program to the thread.

I have an access database called "Database". I have 3 textboxes. "name" "age" and "language" as an example.

When the accept button is clicked, i want that information to update to the database.

I can only do it with a datagridview, but now i want to do it without, as there is no need for it.

Thank you
Rua

Yes you can do it without gridview.. you just need to write a Updatae query to update the data in database..

your code looks like below..

OleDbCommand objCmd = new OleDbCommand();
objCmd.Connection = objCon;
objCmd.CommandText = "Update yourtablename Set col1=@col1, col2=@col2 Where idcolum=@idcol";
objCmd.Parameters.AddWithValue("@col1", txtnam.Text);
objCmd.Parameters.AddWithValue("@col2", txtnam.Text);
objCmd.Parameters.AddWithValue("@idcol", txtID.Text);
objCon.Open();
objCmd.ExecuteNonQuery();
objCon.Close();

That worked perfectly, =),
Thank you =)

that's all.. try by above code and let me know...

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.