i have a huge large text file (350.000 lines) that i want to import to
a MS Acccess Database, of course i don't want to use Access, but do it
with C#.
i already have tried the AddRow method or Insert, reading each line of
the text file, the problem of course is velocity, it would take more
than 4 hours to add all lines/records to the database.
any suggestion?
thank you
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"mfrsousa" <mfrs...@gmail.com> wrote in message
news:1173042613.0...@t69g2000cwt.googlegroups.com...
Robin S.
-----------------------
"mfrsousa" <mfrs...@gmail.com> wrote in message
news:1173042613.0...@t69g2000cwt.googlegroups.com...
In your situation I surely would check if I am not able (and I am) to make a
Zip method in my program.
Then I can save it as a Image file.
Cor
"mfrsousa" <mfrs...@gmail.com> schreef in bericht
news:1173042613.0...@t69g2000cwt.googlegroups.com...
Robin S.
---------------------------------------
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:OiRaaVuX...@TK2MSFTNGP03.phx.gbl...
I am not sure if I understand you?
I know that updating a Jet database goes slow.
Cor
"RobinS" <Rob...@NoSpam.yah.none> schreef in bericht
news:66Gdnb5spbLCMnbY...@comcast.com...
¤ hi there,
I don't know what the format of your text file is but you can use a SQL statement to perform this
operation:
Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
& _
"Data Source=C:\Test Files\db1 XP.mdb")
AccessConn.Open()
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [ReportFile] FROM
[Text;DATABASE=C:\Documents and Settings\...\My Documents\My Database\Text].[ReportFile.txt]",
AccessConn)
AccessCommand.ExecuteNonQuery()
AccessConn.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)
>>> In your situation I surely would check if I am not able (and I am) to
>>> make a Zip method in my program.
>>> Then I can save it as a Image file.
And I don't understand how that helps the OP with his problem of loading a
large file into a database. So I'm asking for clarification.
Robin S.
---------------------------------
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:ude5SquX...@TK2MSFTNGP05.phx.gbl...
--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
Visit www.hitchhikerguides.net to get more information on my latest book:
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook)
-----------------------------------------------------------------------------------------------------------------------
"Paul Clement" <UseAdddressA...@swspectrum.com> wrote in message
news:f2aou21l4eesup20e...@4ax.com...
That is easy when a textfile is zipped it is mostly 100 times as small and
with that will improve the storing time.
Cor
"RobinS" <Rob...@NoSpam.yah.none> schreef in bericht
news:17idnUWfMtKCo3HY...@comcast.com...
Hi Paul,
Thank for our help
I had already tried something similar but was getting errors, i've
tried your code and still got some errors, as the error is in the SQL,
and i'm not very comfortable with SQL, maybe you can help me, here is
my code:
/************************ CODE ******************/
string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|
DataDirectory|\\db.mdb";
string oledbstr = "INSERT * INTO [tblExtData] FROM [Text;DATABASE=F:\
\Projects\\KJStudio\\KJStudio\\bin\\Debug\\].[file.txt]";
OleDbConnection oleconn = new OleDbConnection(conn);
oleconn.Open();
OleDbCommand newcom = new OleDbCommand(oledbstr, oleconn);
newcom.ExecuteNonQuery();
/******************* END CODE ********************/
tblExtData is a table in db.mdb
file.txt is the text file
and the error is ERROR IN INSERT INTO STATEMENT.
Thank you all for the help
Robin S.
---------------------------------------
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:e5MoH50X...@TK2MSFTNGP02.phx.gbl...
> But you can't load a zipped file into Access
Read my message to the OP until the last sentence. It has nothing to do with
space, loading a small file takes just less time than a hug file.
Cor
"RobinS" <Rob...@NoSpam.yah.none> schreef in bericht
news:2ZedndmhQ4TJLnHY...@comcast.com...
¤
¤ I had already tried something similar but was getting errors, i've
¤ tried your code and still got some errors, as the error is in the SQL,
¤ and i'm not very comfortable with SQL, maybe you can help me, here is
¤ my code:
¤ /************************ CODE ******************/
¤ string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|
¤ DataDirectory|\\db.mdb";
¤ string oledbstr = "INSERT * INTO [tblExtData] FROM [Text;DATABASE=F:\
¤ \Projects\\KJStudio\\KJStudio\\bin\\Debug\\].[file.txt]";
¤
¤ OleDbConnection oleconn = new OleDbConnection(conn);
¤ oleconn.Open();
¤ OleDbCommand newcom = new OleDbCommand(oledbstr, oleconn);
¤ newcom.ExecuteNonQuery();
¤ /******************* END CODE ********************/
¤
¤ tblExtData is a table in db.mdb
¤ file.txt is the text file
¤
¤ and the error is ERROR IN INSERT INTO STATEMENT.
Does file.txt have a column header? In order to perform the INSERT without specifying column names,
the column names must match in both the source and destination. If the source is a comma delimited
file, and the first row does not contain a column header that identifies the column names, then the
column names default to F1, F2, F3, etc. Below is an example which specifies the column names as
they are different in the source and destination:
INSERT INTO [tblExtData] (Col1, Col2, Col3) SELECT F1, F2, F3 FROM [Text;F:\
\Projects\\KJStudio\\KJStudio\\bin\\Debug\\;].[file.txt]
Robin S.
---------------------------------------
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:eBBin74X...@TK2MSFTNGP03.phx.gbl...
> Zipping the file only makes it smaller on the disk. It doesn't make it
> have fewer records.
What do you mean by that, I really cannot understand what you mean with this
sentence. Do you mean that it is important for the loading time what the
database is loading. A loading a zippfile is just one transaction, which can
be written with an execute.nonquery and what I never be tried but should be
possible even to be read by an executescalar.
>And you can't load a zip file into Access.
I find it great that you know what I can, an object is just an object and
can as far as I know be written as a bytearray (BLOB) in Access in the same
way as in SQL server.
Cor
If you read the original post again you will notice that question was
how to IMPORT data from a text file into Access database not how to
SAVE text file in a database. This is why RobinS try to say that
zipping a text file wont help this process.
Robin S.
------------------------------------------
"mojeza" <naj...@hotmail.com> wrote in message
news:1173272208....@n33g2000cwc.googlegroups.com...
Why not, if I would ask you how can I in the easiest way make this routine
bellow quicker, what would you than answer.
dim a as float
for I as integer = 0 to 100000000000000
a = a + 1
end for
It is in my opinion almost exactly my answer.
Update(Zip(MyFile))
MyFile = Unzip(Execute.Scalar(Select myfilecolumn from Server where bla
a) )
Cor
"RobinS" <Rob...@NoSpam.yah.none> schreef in bericht
news:d7udnX24-_WMnXLY...@comcast.com...
what would you than answer?
what would be your answer then?
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> schreef in bericht
news:e0OYUePY...@TK2MSFTNGP03.phx.gbl...
> Robin,
>
> Why not, if I would ask you how can I in the easiest way make this routine
> bellow quicker, what would you than answer.
>
> dim a as float
> for I as integer = 0 to 100000000000000
> a = a + 1
> end for
>
> It is in my opinion almost exactly my answer.
>
> Update(Zip(MyFile))
>
> MyFile = Unzip(Execute.Scalar(Select myfilecolumn from Server where bla
Robin S.
---------------------------------------
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:%23ohiT1Q...@TK2MSFTNGP03.phx.gbl...
The difficult is that you only can use it to store with a program. As soon
as you try to use it in by instance Office Access than it is impossible.
However you can try it just as you do a blob. If you want a sample. on the
website from Ken and me is more than enough about that.
If there is a problem than tell it (you are amongst those who I will help
via mail as well).
Cor
"RobinS" <Rob...@NoSpam.yah.none> schreef in bericht
news:oI2dnQXyrYgPaG3Y...@comcast.com...
Have a great day!
Robin
---------------------------------------------
"Cor Ligthert [MVP]" <notmyfi...@planet.nl> wrote in message
news:%23tMyMCn...@TK2MSFTNGP05.phx.gbl...