Hi,
I need some held.
I want to transfer the datatable into my database by using OleDb so please help me.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 12, 2015, 11:44 PM EST
Need more information.
what language are you using for transfer the data?
have you done any code?
Munesh SharmaRank #174 · 13.9K reputationPosted Feb 13, 2015, 12:05 AM EST
http://www.codeproject.com/Articles/17169/Copy-Data-from-a-DataTable-to-a-SQLServer-Database
Create a User-Defined TableType in your database:
CREATE TYPE [dbo].[MyTableType] AS TABLE(
[Id] int NOT NULL,
[Name] [nvarchar](128) NULL
)
and define a parameter in your Stored Ptocedure:
CREATE PROCEDURE [dbo].[InsertTable]
@myTableType MyTableType readonly
AS
BEGIN
insert into [dbo].Records select * from @myTableType
END
and send your DataTable directly to sql server:
using (var command = new SqlCommand("InsertTable") {CommandType = CommandType.StoredProcedure})
{
var dt = new DataTable(); //create your own data table
command.Parameters.Add(new SqlParameter("@myTableType", dt));
SqlHelper.Exec(command);
}
Mohammad Hamza KhanRank #5,059 · 313 reputationPosted Feb 13, 2015, 12:10 AM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 13, 2015, 12:25 AM EST
https://msdn.microsoft.com/en-us/library/system.data.common.dataadapter.update(v=vs.110).aspx
http://csharp.net-informations.com/dataadapter/updatecommand-oledb.htm
hope this will help you.