473,508 Members | 2,370 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New records in Datagrid to be inserted into SQL table. URGENT!

SK
Hi
i m populating a datagrid with data from excel. is it possible to take the datatable in this dataset and create the same as a new table in SQl database. can some one gimme ideas to solve the same in different way

Nov 18 '05 #1
4 1087
Well you can write a generic function in your data access layer. first run a
check to see if you have the table in your db, next iterate the dataset and
start inserting records.

* Get the Table myDT from the DataSet myDS
* You will have to juggle a bit to create the create table statement from
the DataTable
* execute the create table and then do a "select * from tablename " from sql
server
* once you get the new dataset newDS,
iterate the myDT (using i)
call newDS.Tables[0].ImportRow(myDT.Rows[i]
once done importing the rows
newDS.Tables[0].AcceptChanges

i did start coding but it will take me a while plus i gotta leave for work
now.. will do something of this sort in the evening and post it if necessary

Chao,

Hermit Dave
"SK" <an*******@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
Hi,
i m populating a datagrid with data from excel. is it possible to take the datatable in this dataset and create the same as a new table in SQl
database. can some one gimme ideas to solve the same in different ways

Nov 18 '05 #2
Here's one approach: connect to the Excel data source using Jet OLEDB
and execute a SELECT..INTO query using the IN keyword to specify the
SQL Server target e.g.

SELECT *
INTO [odbc;Driver={SQL
Server};Server=MyServer;Database=MyDatabase;User
ID=sa].[NewTempTable]
FROM [Sheet1$]

--

"SK" <an*******@discussions.microsoft.com> wrote in message news:<B8**********************************@microso ft.com>...
Hi,
i m populating a datagrid with data from excel. is it possible to take the datatable in this dataset and create the same as a new table in SQl database. can some one gimme ideas to solve the same in different ways

Nov 18 '05 #3
sk
i tried this
testAdapter = New OleDbDataAdapter("SELECT * INTO [odbc;Driver={SQLServer};Server=MyServer;Database=I nputData;uid=sa;].[NewTempTable] FROM [companyRelation22$]", strConn)
which gave the error
error : ODBC--connection to '{SQLServer}MyServer' failed.

so, when i changed it to

testAdapter = New OleDbDataAdapter("SELECT * INTO [SQLOLEDB;Driver={SQLServer};Server=MyServer;Databa se=InputData;uid=sa;].[NewTempTable] FROM [companyRelation22$]", strConn)

it gives the following error
error : Could not find installable ISAM

the strConn connection parameter is proper.
Can you please gimme more details on this as it is very urgent.

Nov 18 '05 #4
sk
hi
can you please gimme the next steps to complete the task. i tried some insertcommands but of no use...

Nov 18 '05 #5

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

Similar topics

1
10791
by: Patrizio | last post by:
Hi All, I've the following table with a PK defined on an IDENTITY column (INSERT_SEQ): CREATE TABLE MYDATA ( MID NUMERIC(19,0) NOT NULL, MYVALUE FLOAT NOT NULL, TIMEKEY ...
2
13368
by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. ...
2
3104
by: M Wells | last post by:
Hi All, I need to change a column value in several thousand records in a table and output a list of the record ids of the records I've updated into another table. The table, however, is being...
20
40039
by: Guru | last post by:
Hi I have a table which contains number of rows. I want to fetch the last 5 records from the table. I know for the first 'n' records we can use FETCH FIRST n ROWS ONLY command. But i want to...
1
1263
by: Muhammad Usman | last post by:
Respected Assistant I have table in a database named "student" having fields like name of student,Roll No and Status.The status is one of them absent,present or leave.The name and rollno field...
8
2012
by: Strahimir Antoljak | last post by:
I bound a DataGrid to a table (I tried with a DataView too). I removed the row from the table, and then inserted a new row at the same row index. the table gets the row to the right position, but...
5
4005
by: JSParker1 | last post by:
Summary: Maximum number of records per second that can be inserted into SQLServer 2000. I am trying to insert hundreds (preferably even thousands) of records per second in to SQLServer table...
7
6612
by: ebindia0041 | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, Asp.net 1.1 with c# I'm inserting simple records into a table. But one...
1
2599
by: Miley | last post by:
Hi everyone, This is my question/problem. I have a table with orders and a table with order details. Clients can order multiple products at once during one order, so one line has to be inserted...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7323
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,...
0
7379
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...
1
7038
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...
0
7493
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...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4706
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...
0
1550
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 ...

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.