473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Best way to save a datatable into SQL server

Hi,

I have a datatable object in memory, the datasource is not from SQL server.
I want to save this datatable into SQL server 2000, what is the best way to
do it?

The only way I know is to create table dynamically then loop thru datatable
generate and execute an insert statement per row. Quite tedious.

TIA
Jan 19 '06 #1
1 2656
John,

You might have to create the table dynamically, but once you do that,
you should be able to create a SqlDataAdapter and pass the table to the
adapter with the InsertCommand set.

You will probably have to call the SetAdded method on each row of the
data table to set the row state to added (in case it was not), so that the
adapter will recognize the state as being changed.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"John" <so*****@microsoft.com> wrote in message
news:OT**************@tk2msftngp13.phx.gbl...
Hi,

I have a datatable object in memory, the datasource is not from SQL
server. I want to save this datatable into SQL server 2000, what is the
best way to do it?

The only way I know is to create table dynamically then loop thru
datatable generate and execute an insert statement per row. Quite tedious.

TIA

Jan 19 '06 #2

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

Similar topics

1
by: Rob | last post by:
I was looking for the easiest way to take a datagrid full of data including two template columns, and export the contents of the grid into Excel by giving an "open or save as" box. I came across...
8
by: Art | last post by:
Hi folks, I'm writing a traditional desktop app using VB.NET and am stumbling over what seems like a very basic question: My app does not need to be connected to a server or another computer....
0
by: jimmyfo | last post by:
Hi, I've got some questions concerning getting the save dialogue to popup when a link is clicked on. The particular issue I'm having is that the file is returned dynamically (via a search) and I...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
13
by: Martin Z | last post by:
I'm making a CRUD screen for an Oracle database... but problem is that the primary key in that table is populated via an autonumber, which in Oracle is done just with triggers and sequences. ...
7
by: Steve | last post by:
I am building an object library for tables in a database. What is the best practice for creating objects like this? For example, say I have the following tables in my database: User: - Id -...
3
by: Kevin | last post by:
I have a Windows Forms app with a form that displays/updates student data. When it activates I fill a DataTable with just the names of the students from a table of about 10,000 names. I have...
2
by: chike_oji | last post by:
Please can someone help me. I am writing a web application, that allows for the upload of an excel sheet into the database. I have an upload button and a save button. The upload button allows...
8
by: Siv | last post by:
Hi, What is the best way to get the field names of a table in SQL server where you only have Windows Authentication access to a database. Previously I have used the SQLDMO object to get this, but...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.