Bulk Copy From Datatable To SQL Server Table

1. January 2010

 public bool BulkEnterData(DataTable dt, string tblName)
    {
        SqlBulkCopy bulk = new SqlBulkCopy(con);
        bulk.DestinationTableName = tblName;
       
        con.Open();
        bulk.WriteToServer(dt);
        con.Close();

        return true;
    }

 

 

to run sqlbulkcopy u must define listed below if it give u an error {A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 - The pipe has been ended.)}

Go to Start -> Programs -> Microsoft SQL Server 2005 -> Configuration Tools -> SQL Server Surface Area Configuration.

 

Then go to "Surface Area Configuration for Services and Connections"

 

Then select "Remote Connections" under "Database Engine" option.

 

Then select "Using both TCP/IP and named pipes" radio button under Local and remote connections.


Author: Aamir Hasan     औथोर: आमिर हसन       أثر أمير حسن .

ALL, CSharp, SQL 2005 & 2008 , , ,


Comments

Comments are closed

User Name: Guest

Your Ip: 38.107.191.90
Time: