John
John

Reputation: 223

Write one value to an SQL table from vb.net

From within my VB.Net program, I would like to write to one specific column of a row in a table in an SQL database, given the row's primary key. What is the lowest-overhead means of doing this? I understand how to create a table adapter, fill a datatable, write to the datatable and then update the database. Is there a relatively simple way to directly access the database table instead?

Upvotes: 0

Views: 463

Answers (2)

Anders Abel
Anders Abel

Reputation: 69260

If it really is that simple - create a SqlCommand with a sql update statement.

The solution is simple, efficient and requires very little code overhead. However it is definitely not recommended for larger applications as it will be a pain to maintain in larger scale.

Upvotes: 2

tmesser
tmesser

Reputation: 7656

The simplest way to access a database in VB.NET is going to be to use a SqlCommand object combined with a SqlConnection. Even that is going to require 5-7 lines of code to do anything from your perspective, but if you want to get any thinner/simpler than that you're typically going to have to start looking into ORMs or data wrapper classes.

Upvotes: 2

Related Questions