Hello i have a database table

| col1 | col2 | col3 | col4 | col5 |
|  val |  val |  val |  val |  val |
|  val |  val |  val |  val |  val |
|  val |  val |  val |  val |  val |
|  val |  val |  val |  val |  val |
|  val |  val |  val |  val |  val |
|  val |  val |  val |  val |  val |
|  val |  val |  val |  val |  val |

and a datatable

| col1 | col2 | col3 | 
|  val |  val |  val |  
|  val |  val |  val | 
|  val |  val |  val | 
|  val |  val |  val | 
|  val |  val |  val |

I want to update just the col1 col2 and col3 in database table via datatable
how can i do this? thank you

Recommended Answers

All 3 Replies

To update a DataSet and send those updates back to the database, follow these steps:

Open Microsoft Visual Studio .NET.
Create a new Console Application in Visual Basic .NET. By default, Visual Studio creates a Static Module and an empty Main() procedure.
Make sure that the project contains a reference to the System and System.Data namespaces. Use the Imports statement on the System, SystemData, and System.Data.SqlClient namespaces

use for loop and select only those columns that you want to update..... ^_^

i don't want to use loop. its so heavy for the computer to work for large amount of data
I have a datagrid view that when you change the first column data like for example

|col1 |col2 |col3 |col4|
|  1  |  5  |  9  | 13 |
|  2  |  610 | 14 |
|  3  |  7  |  11 | 15 |
|  4  |  8  |  12 | 16 |

// when i edit col1 row 3 other columns will adjust
// like it will increment by 1


|col1 |col2 |col3 |col4|
|  1  |  6  |  10 | 14 |
|  2  |  7  |  11 | 15 |
|  4  |  8  |  12 | 16 |
|  5  |  9  |  13 | 17 |

so every data is being updated.
col1,col2,col3,col4 are save in one column in my database table column Qnty
if i use loop it is to slow.

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.