473,609 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

updating database using datatable

hi guys...

i am a student, i am studying and i am a newbie in VB.net and i am
using SQL Server 2000.

I have this datatable which i insert rows (may take up to 2 or more
rows because i would like to perform batch updating). upon clicking of
update button, i would like to insert them all in a table in my
database.

I know this question has been posted before but could you show me guys
a sample code or a link to a code where i can study how to update a
database by a datatable.

help in anyway is very much appreciated.

Thanks

Joel - newbie

Sep 19 '07 #1
1 8207
Hi Joel,

A DataTable is a disconnected set of data. It may or may not be data from a
database, or have anything to do with a database. When a DataTable is
populated from a database, it must be populated by a DataReader, either as a
member of a DataAdapter, or independently. The DataReader or DataAdapter has
the Connection to the database. So, to insert data into a database, either a
Connection and Command must be used, or a DataAdapter, which contains a
Connection and a set of Commands must be used. In any case, the data is not
literally updated as a batch, but in a looping construct that inserts the
records one at a time. How you wish to do the insertion work is up to you.
For more information, see the following:

http://msdn2.microsoft.com/en-us/lib...x7(VS.71).aspx
http://msdn2.microsoft.com/en-us/lib...wf(VS.71).aspx
http://msdn2.microsoft.com/en-us/lib...8z(VS.71).aspx

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"joel" <co*********@ho tmail.comwrote in message
news:11******** **************@ n39g2000hsh.goo glegroups.com.. .
hi guys...

i am a student, i am studying and i am a newbie in VB.net and i am
using SQL Server 2000.

I have this datatable which i insert rows (may take up to 2 or more
rows because i would like to perform batch updating). upon clicking of
update button, i would like to insert them all in a table in my
database.

I know this question has been posted before but could you show me guys
a sample code or a link to a code where i can study how to update a
database by a datatable.

help in anyway is very much appreciated.

Thanks

Joel - newbie

Sep 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
5283
by: sandman | last post by:
I've got a simple windows form with some bound textboxes and Save button. Each texbox is bound to column in a table in an Access database. The form fills fine - all the fields show the correct data for the record I load. So then I change the contents of one of the textboxes and click on the Save button. The button's event handler then calls the data adapter's Update method and I check the return value. Nada-zilch-nothing. I even put a...
3
1792
by: Jon Agiato | last post by:
Hi, I am trying to use a data grid in a web application in which I have three tiers. The DataGrid is not set up to a data source, or a data adapter, so everytime I make a change I send the cell information to another object which forms an SQL query and makes the query to the DB (actually to a DBFacade object). In any case, please see the code I have listed below for my update DataGrid event. With this code, the DB is updated using the old...
1
2460
by: Luis Esteban Valencia | last post by:
Hello Everyone, Iam an intermediate ASP.Net programmer and iam facing a challenging task. I have a table in MS-SQL server database called 'Members'. The table has following fields... mem_id integer primary key lastname nvarchar(30) firstname nvarchar(30)
13
2077
by: Doug Bell | last post by:
Hi, I thought I had this sorted this morning but it is still a problem. My application has a DataAccess Class. When it starts, it: Connects to a DB (OLE DB) If it connects it uses an OleDbCommand with an SQL String and the connection it has a DataAdapter with the command then it fills the DataSet's DataTable with the streamed data.
3
8920
by: RSH | last post by:
Hi, I have a situation in where i have two instances of SQL server, the first is our Production Environment, the second is our Development environment. Both servers contain the same databases but I need to write a utility that can transfer a row of data from the Production to the Development servers. I wrote the code below, which doesn't error...but it doesn't work...no data is updated. This is very odd because I can see that both of...
6
13987
by: Rich | last post by:
Dim da As New SqlDataAdapter("Select * from tbl1", conn) dim tblx As New DataTable da.Fill(tblx) '--works OK up to this point da.UpdateCommand = New SqlCommand da.UpdateCommand.Connection = conn da.UpdateCommand.CommandText = "Update tbl1 set fld1 = 'test' where ID = 1" da.Update(tblx) '--tblx/tbl1 not getting updated here.
0
1222
LoanB
by: LoanB | last post by:
Hey guys need some info here. I am adding, updating and deleting data on a datagrid. I pass the datagrid's datasource (datatable dt) to my data layer. Assuming I have already created and opened a connection in a business layer and passed it to my datalayer I am now stuck here: My business layer code is as follows: //UPDATE MATRIX STOCK DATA TO SQL DATABASE public void updateMatrixData(System.Data.DataTable dt)
1
2362
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will need updating with 'CLOSED' where necessary.) I have been trying to use the OLEDB command builder to build the statement to update the database however it is returning an error whenever I try to do this. I already have a dataset full of data, 1...
1
1930
by: Wavey | last post by:
Hi All, I have a problem with updating an Access database from a datatable. I have two rows of data in my database at the moment for testing, the first row is an ID number (primary key), the second is a name and the third is a price. I can get this data out of the database, store it in a datatable in a dataset and display the name in a listbox with the name and price displayed in textboxes. If I change the data for the second row data...
0
8091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8579
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8555
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5524
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.