0

Im converting code from VBA into c# and it is all about creating looong string and inserting it into MSSQL ntext field, im not kinda sure about the string`s size, but it looks rather too long for me. In VBA code insert statement looks like this:

With rstFormat
    .AddNew
.Fields("field").Value      = b
.Fields("field2").Value     = "a"
FillBLOB .Fields("loongstring"), loongstring

So, i guess, FillBlob is a good idea, but how i can do the same with c#?

I am using ADO.NET.

4

1 回答 1

0

What about assigning a string variable to the NTEXT parameter like this:

SqlCommand mySqlCommand_new;
mySqlCommand_new = SQLConnection.CreateCommand();
mySqlCommand_new.CommandText = "insert table (column) values(@text)";
mySqlCommand_new.Parameters.Add(new SqlParameter("@text", SqlDbType.NText));
mySqlCommand_new.Parameters["@code"].Value = text;
mySqlCommand_new.ExecuteNonQuery();

http://social.msdn.microsoft.com/Forums/en-US/transactsql/thread/2eee04ec-7510-42aa-97ea-8163b40c4c9b/

于 2012-08-23T08:47:41.677 回答