INserting Text

Discussion in 'ASP .Net' started by Yama, Jan 15, 2004.

  1. Yama

    Yama Guest

    Hello,

    Can someone tell me how to insert text into a table containing a TEXT field?
    How to update?

    I would like to create a stored procedure that take a text parameter and
    inserts it into a new column in my table. Then do the same stored procedure
    but this time to update the TEXT field.

    HELP!

    Yama
     
    Yama, Jan 15, 2004
    #1
    1. Advertising

  2. Yama

    Yama Guest

    My Dear Newsgroup,

    Here is how I settled doing it.

    In my ASPX web page I have four fields. A dropdown with a list of all the
    letters, a checkbox for activating a letter or setting it to innactive, a
    text box for the description of a letter, and another text box for the
    letter with multiple line enabled. Hope you like this... :)

    --The table:
    CREATE TABLE [dbo].[tblLetter] (
    [LetterID] [numeric](9, 0) IDENTITY (1, 1) NOT NULL ,
    [Letter] [text] COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [Description] [varchar] (100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [Active] [bit] NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

    --The stored procedure:
    CREATE PROCEDURE SaveLetter

    @Description VARCHAR(100) = '',
    @Active BIT = 1,
    @BlobLetter TEXT = '',
    @blnInsert BIT = 0,
    @LetterNumber INT = NULL,
    @blnDelete BIT = 0

    AS

    DECLARE @s BINARY(16)

    IF @blnInsert = 1 AND @blnDelete = 0
    BEGIN
    BEGIN TRAN
    DECLARE @ID INT

    INSERT INTO tblLetter
    (Description, Active, Letter) VALUES (@Description, @Active, @BlobLetter)

    SET @ID = @@IDENTITY

    SELECT @s = TEXTPTR( Letter )
    FROM tblLetter
    WHERE LetterID = @@IDENTITY

    WRITETEXT tblLetter.Letter @s @BlobLetter
    COMMIT TRAN
    END

    IF @blnInsert = 0 AND @blnDelete = 0
    BEGIN
    BEGIN TRAN
    UPDATE tblLetter
    SET Description = @Description , Active = @Active
    WHERE LetterID = @LetterNumber

    SELECT @s = TEXTPTR(Letter)
    FROM tblLetter
    WHERE LetterID = @LetterNumber

    WRITETEXT tblLetter.Letter @s @BlobLetter
    COMMIT TRAN
    END

    IF @blnDelete = 1
    BEGIN
    DELETE FROM tblLetter
    WHERE LetterID = @LetterNumber
    END
    GO

    Yama Kamyar
    Senior Microsoft .NET Consultant

    "Yama" <> wrote in message
    news:...
    > Hello,
    >
    > Can someone tell me how to insert text into a table containing a TEXT

    field?
    > How to update?
    >
    > I would like to create a stored procedure that take a text parameter and
    > inserts it into a new column in my table. Then do the same stored

    procedure
    > but this time to update the TEXT field.
    >
    > HELP!
    >
    > Yama
    >
    >
     
    Yama, Jan 19, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jurjen de Groot

    Inserting text into TableCell at runtime

    Jurjen de Groot, Aug 18, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    498
    Xavier MT
    Aug 18, 2003
  2. Ceri
    Replies:
    2
    Views:
    426
    Ceri Locke
    Dec 17, 2003
  3. =?Utf-8?B?Um9iZXJ0IEhhbHN0ZWFk?=

    Problem with text when inserting into text box

    =?Utf-8?B?Um9iZXJ0IEhhbHN0ZWFk?=, Apr 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    413
    Somchai U.
    Apr 27, 2004
  4. =?Utf-8?B?ZGVlcGFrIGt1bWFy?=

    inserting html dropdownlist 's text into blank table

    =?Utf-8?B?ZGVlcGFrIGt1bWFy?=, Nov 2, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    647
    =?Utf-8?B?ZGVlcGFrIGt1bWFy?=
    Nov 2, 2004
  5. darrel
    Replies:
    3
    Views:
    1,361
    Karl Seguin [MVP]
    Apr 7, 2006
Loading...

Share This Page