sqlbulkcopy and total rows inserted.

A

Archana

Hi all,

i am using sqlbulkcopy to insert content to table, how will i get
total rows inserted into table without using any eventing.

and is it possible to do bulk copy from sql table to csv file?

thanks in advance.
 
P

Paul Clement

¤ Hi all,
¤
¤ i am using sqlbulkcopy to insert content to table, how will i get
¤ total rows inserted into table without using any eventing.

You can check the row count just before execution of the bulk copy and then check it immediately
after completion and take the difference (assuming no one else is inserting rows into the table).

¤ and is it possible to do bulk copy from sql table to csv file?

Not with the SQLBulkCopy class. However, you can use a SQL SELECT INTO statement to perform this
operation. Below is an example:

Dim TextConnection As New
System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "E:\My
Documents\TextFiles" & ";" & _
"Extended
Properties=""Text;HDR=NO;""")

TextConnection.Open()

Dim TextCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [Orders#txt] FROM
[Orders] IN '' [ODBC;Driver={SQL
Server};Server=(local);Database=Northwind;Trusted_Connection=yes];", TextConnection)

TextCommand.ExecuteNonQuery()
TextConnection.Close()


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top