data into a ntext field

G

Guest

I want to copy data from a text file into a ntext field in a table in SQL
Server (using ADO.Net). I think you use AppendChunk in classic ADO, but not
sure how to do it in ADO.NET.

Can someone show me the code that I would use ?

Thanks,
Craig
 
G

Guest

Thanks, Cor

I got that to work. But is there a way to do that by using a stored
procedure, instead of passing SQL into the command object.

Thanks, Craig
 
R

Rogas69

yes, there is

you create procedure that gets ntext parameter, like this

CREATE procedure dbo.sp_InsertFromXML
@strXml nText --XML containing data to be inserted
(...)

I use generated dataadapter, but you can do it on your own as well
this.m_commandCollection[1] = new System.Data.SqlClient.SqlCommand();

this.m_commandCollection[1].Connection = this.Connection;

this.m_commandCollection[1].CommandText = "dbo.sp_InsertFromXML";

this.m_commandCollection[1].CommandType =
System.Data.CommandType.StoredProcedure;

this.m_commandCollection[1].Parameters.Add(new
System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue,
10, 0, null, System.Data.DataRowVersion.Current, false, null, "", "", ""));

this.m_commandCollection[1].Parameters.Add(new
System.Data.SqlClient.SqlParameter("@strXml",
System.Data.SqlDbType.NVarChar, 10000000,
System.Data.ParameterDirection.Input, 0, 0, null,
System.Data.DataRowVersion.Current, false, null, "", "", ""));

Take care about type of the parameter and its max length. (here
System.Data.SqlDbType.NVarChar, 10000000)



HTH

Peter
 

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