Inserting large amounts of text using ntext or text

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I am not sure if this is a VB.NET or a SQL Server problem, but those are the
technologies that I am using. I have a stored procedure that accepts
parameters and performs an Insert into my database. Everything works fine,
except for the column that holds a very large (35,000+ characters) amount of
text. I have tried this with both text and ntext datatypes, but I am getting
no results.

The code runs, the stored procedure commits and most of the desired results
are achieved, except that the text column remains blank (not <null>, but
blank). I have tried a great many variations to make this work, but the best
result I have achieved so far is to have the first 16 characters of my string
inserted.

Here is a simplified version of my code (just leaving out a few colums for
clarity):

Dim conConnection As New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

Dim cmdCommand As New SqlCommand("RGW_Add", conConnection)
cmdCommand.CommandType = CommandType.StoredProcedure

cmdCommand.Parameters.Add("@Name", txtName.Text)
cmdCommand.Parameters.Add("@Email", txtEmail.Text)
cmdCommand.Parameters.Add("@Details", Session("Text"))

Dim paramRecordID As New SqlParameter("@RecordID",
SqlDbType.Int, 4)
paramRecordID.Direction = ParameterDirection.Output
cmdCommand.Parameters.Add(paramRecordID)

conConnection.Open()
cmdCommand.ExecuteScalar()
conConnection.Close()



And here is the stored procedure:

ALTER Procedure RGW_Add
(
@Name varchar(250),
@Email varchar(250),
@Details ntext,
@RecordID int OUTPUT
)
AS

INSERT INTO RGW_Orders
(
Name,
Email,
Details

)
VALUES
(
@Name,
@Email,
@Details
)

SELECT
@RecordID = @@Identity



Now, I have modified the portion of the code that declares the "@Details"
parameter as such:

Dim paramDetails As New SqlParameter("@Details", SqlDbType.NText, 1073741823)
paramDetails.Value = Session("Text")
cmdCommand.Parameters.Add(paramDetails)

as well as a few other minor alterations to this syntax.

It has been suggested elsewhere that I declare my column width in my stored
procedure, but Enterprise Manager doesn't allow that. Does anyone else have a
suggestion or tip?

Any help is appreciated.
.



Relevant Pages

  • Re: SQL Send Adapter
    ... I am trying to use this suggestion without success so far. ... Set the field for the XML part of the SQL insert message to distinguished. ... I am clear on how to create the schema and the ports; ... on how to pass the input XML message to the stored procedure. ...
    (microsoft.public.biztalk.general)
  • Re: Inserting large amounts of text using ntext or text
    ... > Have you run your stored procedure in Query Analyzer with sample data? ... I have tried this with both text and ntext datatypes, ... >> @Details ntext, ... >> suggestion or tip? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problem with IN parameters to an Oracle stored procedure
    ... original post with the original post copy pasted below. ... Since then I have changed the IN parameter to my stored procedure to ... based on a suggestion to the earlier post and ... Joe Weinstein at BEA Systems ...
    (comp.lang.java.databases)
  • Re: Inserting large amounts of text using ntext or text
    ... Have you run your stored procedure in Query Analyzer with sample data? ... > Dim conConnection As New ... I have modified the portion of the code that declares the "@Details" ... > suggestion or tip? ...
    (microsoft.public.dotnet.framework.adonet)
  • returning vars from one sp to another
    ... I have debugged using the Query Profiler and found this to be the case, ... stored procedure x is running and calls stored procedure y passing it 3 parameters ... procedure y declares @b, and @c as output parameters, but upon return from y their values are still NULL, Why? ...
    (microsoft.public.sqlserver.programming)