Re: OleDbParameter vs. manually SQL Statement to Insert mass date from host

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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



.



Relevant Pages

  • Re: need help with connect string
    ... Dim Conn As New SqlConnection("Data ... The mydb.mdf is not in the usual Sql server data ... It sounds as if the database was created as part of a user instance. ...
    (microsoft.public.data.oledb)
  • Re: OleDbParameter vs. manually SQL Statement to Insert mass date from host
    ... But I think a bulkcopy is a "external" Database tool, ... Hitchhiker's Guide to Visual Studio and SQL Server ... and Hitchhiker's Guide to SQL Server 2005 Compact Edition (EBook) ... conn = new OleDbConnection; ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SQL Server 2000 to 2005 shows error in classic asp : Row handle referred to a deleted row or a r
    ... Alex Clay wrote: ... SQL Server 2005 from classic asp pages served from a Windows Server ... Set conn = Server.CreateObject ... Is there a tweak on SQL Server 2005 that will allow this code to run? ...
    (microsoft.public.data.ado)
  • Re: bug in ADOX.catalog with SQL Server 7.0 ?
    ... Actually ADOX was designed for using with Access and does not support ... which is not supported in ADOX when you work with SQL Server. ... > conn = open_connection ...
    (microsoft.public.data.ado)
  • Re: Web Service + SqlConnection
    ... Do I do that from Visual Studio or from MS SQL Server 2005? ... Now I've added an SQL Database object Database.mdf into my project. ... Subsequent publishing, however, results in the same message. ... tabljic", conn); ...
    (microsoft.public.dotnet.languages.csharp)