المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Coping data from dataset to table



C# Programming
05-17-2009, 02:12 PM
Hello Experts......

i have problem in my dataset has a table which i retrieve from a file,now i want to copy values from dataset to table.i used SQLBULKCOPY but cant work.

Help me!!

My Code:-


DataTable dt= ds.Tables["MyNewTable"]; // This is a table i have in my dataset
using (SqlBulkCopy bc = new SqlBulkCopy(conn))
{
conn.Open();

bc.DestinationTableName = "dbo.XYZ"; // This is a table wid same schema as MyNewTable.

// Starts the bulk copy.
DataTable dt1=new DataTable("MyNewTable");
bc.WriteToServer(dt); ;

// Closes the SqlBulkCopy instance
bc.Close();
}