Re: OleDbParameter vs. manually SQL Statement to Insert mass date from host
- From: "William \(Bill\) Vaughn" <billvaRemoveThis@xxxxxxxxxx>
- Date: Wed, 13 Dec 2006 09:40:05 -0800
It's not clear that you're using SQL Server. If you are, I suggest (again)
SqlBulkCopy.
--
____________________________________
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)
-----------------------------------------------------------------------------------------------------------------------
<pRumpf@xxxxxxxxxxxxxxx> wrote in message
news:1166029033.768744.45140@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi
I translate an prior application written in Clipper to C#....
The Application reads Cobol Files (EBCDIC, BCD numbers....) and inserts
the data into a rdbms. This part is no problm to realize in C#.
The original App. create SQL Statements as string/text and execute them
with the Database command-Line-Interactiv-SQL Tool (run iSql.exe
"...sql....") because there is no ODBC or OleDB Support in Clipper
e.g.
sql = "insert into t01.data (field1, field2, field3) values (200,
123.90, 'Bread' );
"insert into ......;"
...
Now my Question has onyone experience using OleDBParameter /
performance.
What is the better (speediest) way:
1) Creating the complete sql command as text string and execute (e.g.)
conn = new OleDbConnection( myConnectionString );
conn.Open();
// here is the loop overall Cobol records....
// the values (200, 123.90, Bread) comes out of the Cobol-Record
// to simplify the example:
string sql = "insert into t01.data (field1, field2, field3) values
(200, 123.90, 'Bread' );"
cmd= new OleDbCommand(sql, conn);
cmd.ExecuteNonQuery();
...
2) Using OleDbParameters
conn = new OleDbConnection( myConnectionString );
conn.Open();
string sql = insert into t01.data (field1, field2, field3) values
(?, ? , ?);"
cmd= new OleDbCommand(sql, conn);
// here is the loop overall Cobol records
//...
cmd.Parameters.Clear();
cmd.Parameters.Add("@p1", ...).Value = 200;
cmd.Parameters.Add("@p2", ...).Value = 123,90;
cmd.Parameters.Add("@p3", ...).Value = "Bread";
OleDbDataReader dr = cmd.ExecuteNonQuery();
3) maybe another way.... ?
Which way is the speediest. Has anyone experince ?
Thank you
.
- Follow-Ups:
- References:
- Prev by Date: Re: I have two questions about the TableAdapter Configuration Wizard
- Next by Date: Re: OleDbParameter vs. manually SQL Statement to Insert mass date from host
- Previous by thread: OleDbParameter vs. manually SQL Statement to Insert mass date from host
- Next by thread: Re: OleDbParameter vs. manually SQL Statement to Insert mass date from host
- Index(es):
Relevant Pages
|