473,396 Members | 1,722 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,396 software developers and data experts.

Upd SQL Srvr table with text file

I'm trying to update (insert into) an SQL Server table with a dataset
that I filled from an Odbc dataadapter. I must be dumber than
a rock, but I can't figure it out nor can I find any examples on the
web.

Could someone pleeeeze point me in the right direction?

Tks,
M. Miller
Nov 21 '05 #1
3 1170
Post what you have already. It will help us to get you the rest of the way
there.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Marc Miller" <mm****@hotmail.com> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
I'm trying to update (insert into) an SQL Server table with a dataset
that I filled from an Odbc dataadapter. I must be dumber than
a rock, but I can't figure it out nor can I find any examples on the
web.

Could someone pleeeeze point me in the right direction?

Tks,
M. Miller

Nov 21 '05 #2
Nick,

Thank you for your response and interest in my problem. The code that I am
using to retrieve the text follows. I have tried all sorts of ways to
get the data set from the text retrieval into a data set to update the SQL
Server table, but to not avail.

I appreciate your help.

Marc Miller
'--------------------------------
Dim ConnectionString As String = "Driver={Microsoft Text Driver (*.txt;
*.csv)};DBQ=i:\groups\oracle\empldata\"

Dim conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(ConnectionString)
Dim ds As DataSet = New DataSet

conn.Open()

Dim da As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter("select * from
empsdata.dat", conn)

Try

da.Fill(ds, "empsdata")

'''''' The datagrid is just for verifying the data grab.

dg.SetDataBinding(ds, "empsdata")

'''''''

'''' The next step is to load it into an SQL Server Table.

Catch ex As OdbcException

MessageBox.Show(ex.Message)

End Try

conn.Close()


"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:Fr********************@comcast.com...
Post what you have already. It will help us to get you the rest of the way there.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Marc Miller" <mm****@hotmail.com> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
I'm trying to update (insert into) an SQL Server table with a dataset
that I filled from an Odbc dataadapter. I must be dumber than
a rock, but I can't figure it out nor can I find any examples on the
web.

Could someone pleeeeze point me in the right direction?

Tks,
M. Miller


Nov 21 '05 #3
Hi Marc,

There is nothing wrong, in theory, with using the same dataset object to
read from one database and write to another. However, you have to translate
your field and table names.

Once you read the dataset, you will need to create a table mapping to change
the column and field names for output.
http://msdn.microsoft.com/library/en...asettables.asp

I'll be honest with you... this approach is for experts. While you end up
with less code, it is not something that can be easily explained.

If you do not feel comfortable with the level of detail in the
documentation, or the references to XML Schemas, you may be better off
simply using your dataset as an input mechanism, and then, taking each row
from the input and submitting a stored procedure call to write the data, one
row at a time, to the target database. It's more code, but it's more
achievable, and you'll understand it when you are done.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Marc Miller" <mm****@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Nick,

Thank you for your response and interest in my problem. The code that I am using to retrieve the text follows. I have tried all sorts of ways to
get the data set from the text retrieval into a data set to update the SQL
Server table, but to not avail.

I appreciate your help.

Marc Miller
'--------------------------------
Dim ConnectionString As String = "Driver={Microsoft Text Driver (*.txt;
*.csv)};DBQ=i:\groups\oracle\empldata\"

Dim conn As Odbc.OdbcConnection = New Odbc.OdbcConnection(ConnectionString) Dim ds As DataSet = New DataSet

conn.Open()

Dim da As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter("select * from
empsdata.dat", conn)

Try

da.Fill(ds, "empsdata")

'''''' The datagrid is just for verifying the data grab.

dg.SetDataBinding(ds, "empsdata")

'''''''

'''' The next step is to load it into an SQL Server Table.

Catch ex As OdbcException

MessageBox.Show(ex.Message)

End Try

conn.Close()


"Nick Malik [Microsoft]" <ni*******@hotmail.nospam.com> wrote in message
news:Fr********************@comcast.com...
Post what you have already. It will help us to get you the rest of the

way
there.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Marc Miller" <mm****@hotmail.com> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
I'm trying to update (insert into) an SQL Server table with a dataset
that I filled from an Odbc dataadapter. I must be dumber than
a rock, but I can't figure it out nor can I find any examples on the
web.

Could someone pleeeeze point me in the right direction?

Tks,
M. Miller



Nov 21 '05 #4

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

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
1
by: Brett | last post by:
We have an application where the iusr_<srvr> has write NTFS permissions to a folder under the wwwroot (i.e. wwwroot\folder) and also there is a SQL Server database where we must give the...
4
by: spwpreston | last post by:
Hello, I am new to MySQL. I am trying to load from a text file to a table, and am having problems with the fields in the text file being translated to the correct fields in the TABLE. Right...
1
by: John Shadel | last post by:
I have the following setup: 1. ASP.NET 2.0 web app hosted on a web server (inetpub directory hosting physical files of the web site on a different drive name, E: than the SQL Server Instance,...
1
by: Rahul | last post by:
Hi, I tried many option, but did not found solution. Same Validation Error showing. If I have convert one table, it can easily converted. But If I have paste another table in same file, then...
3
by: Daniel Wetzler | last post by:
Dear MSSQL- experts, I have a strange problem with SQLSERVER 2000. I tried to export a table of about 40000 lines into a text file using the Enterprise manager export assitant. I was astonished...
4
by: Bob | last post by:
Hi all, I've got a table that I've imported and it has junk at the top of the table, so after import I run a delete query to remove the junk lines then I'm left with the field names I want for...
6
by: Romulo NF | last post by:
Greetings again to everyone, Im back to show this grid componenet i´ve developed. With this grid you can show the data like a normal table, remove the rows that you need, add rows, import data,...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
0
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
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...
0
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...

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.