473,811 Members | 2,540 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1178
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******** ******@TK2MSFTN GP12.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 ConnectionStrin g As String = "Driver={Micros oft Text Driver (*.txt;
*.csv)};DBQ=i:\ groups\oracle\e mpldata\"

Dim conn As Odbc.OdbcConnec tion = New Odbc.OdbcConnec tion(Connection String)
Dim ds As DataSet = New DataSet

conn.Open()

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

Try

da.Fill(ds, "empsdata")

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

dg.SetDataBindi ng(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*******@hotm ail.nospam.com> wrote in message
news:Fr******** ************@co mcast.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******** ******@TK2MSFTN GP12.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******** *******@TK2MSFT NGP12.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 ConnectionStrin g As String = "Driver={Micros oft Text Driver (*.txt;
*.csv)};DBQ=i:\ groups\oracle\e mpldata\"

Dim conn As Odbc.OdbcConnec tion = New Odbc.OdbcConnec tion(Connection String) Dim ds As DataSet = New DataSet

conn.Open()

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

Try

da.Fill(ds, "empsdata")

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

dg.SetDataBindi ng(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*******@hotm ail.nospam.com> wrote in message
news:Fr******** ************@co mcast.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******** ******@TK2MSFTN GP12.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
8155
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. -------------------- ---------- ---------- ------- ------- 21/03/2005-04:06:03 XX,XX XX,XX 171 3,42 21/03/2005-12:23:53 XX,XX XX,XX 500 5,4 21/03/2005-12:43:10 XX,XX XX,XX 553 5,38
1
2779
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 iusr_<srvr> read and write permissions on the database in order for the application to work. Anonymous access is enabled on the default web site where this web app is located. Because we are using the iusr is there simple exploit code that could allow...
4
2280
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 now, I have a tab between each field in the text file, something like: Chicago USA 2,500,000 New York USA 5,000,000
1
4729
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, which is on C:) 2. SQL Server on the same server, with security settings enabling ASPNET group and groups containing users allowed to interact with the website added to SQL Server Instance security settings. 3. Impersonation = true, i.e. ASPNET...
1
1583
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 showing validation Error. This Error is -- =======================================================
3
3962
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 to get an exported text file of about 400 MB instead 16 MB which is the normal size of that data. By examining this file with a text editor I found that the file included alongside the data of my table MANY zeros which caused the big file size.
4
22582
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 the table at the top of the table but the field names currently are 'field1' etc, so how do I rename the field names to the fields on the top row of the table. Cheers,
6
7999
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, call determined functions, and edit the data already present What will you need to use the grid? A table with standard markup and an ID to call the script that will turn the table into a grid Parameters: tabelaID => id of the table that will...
3
4439
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 when iam using a normal web page... but can't in content page.... Code in Master Page <%@ Master Language="C#" AutoEventWireup="true" CodeFile="submaster.master.cs" Inherits="submaster" %> <%@ Register Assembly="AjaxControlToolkit"...
0
9605
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
10651
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
10392
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...
0
10136
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...
1
7671
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
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
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
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
2
3868
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.