473,385 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

INserting Text

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
Nov 18 '05 #1
1 1342
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" <yk*****@grandpacificresorts.com> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
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

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: pmud | last post by:
I have an ASP.NET web application using C# code. I am trying to insert values from a web form into an SQL database. I am using SQL COMMAND object for this. I need to know HOW TO INSERT THE RADIO...
6
by: Pushpendra Vats | last post by:
Hi , I am trying to insert records into database. I am trying to write the following code. On button1 click event i am inserting five records and after that i am calling the update method of...
5
by: aniket_sp | last post by:
i am using a data adapter and a dataset for filling and retrieving data into .mdb database. following is the code..... for the form load event Dim dc(0) As DataColumn Try If...
1
by: ing42 | last post by:
I have a problem with inserting records into table when an indexed view is based on it. Table has text field (without it there is no problem, but I need it). Here is a sample code: USE test GO...
0
by: pd123 | last post by:
I'm new to C# and .net and I'm trying to create a form that will register users in a sql server database. I have the following code but when I run the code I get an error " The name 'Peter' is...
3
by: rcoco | last post by:
Hi, I want to share this problem. I have a datagrid that will help me Insert data into sql database. So I made a button On my form so that when I press the button a new row on datagrid should be...
13
by: imnewtoaccess | last post by:
Hi, I am getting errors while inserting records in one table from another. These are the structures of two tables : file51tm_new RecordType Text
14
by: rashmidutt | last post by:
hello sir i am making project on vb.net language..and project is on hospital management..its major project..and too many fields are present in its data base..i was connecting data base in forms but...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
5
by: atlanteavila | last post by:
Hello all, I have a problem with inserting text with quotes, or html code in to a MYSql Database. I've been trying to create my own content management system, and unfortunately I've come accross a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.