Home All Groups Group Topic Archive Search About

Storing Richtextbox data In Sql

Author
30 Dec 2005 11:31 PM
den 2005
Hi everybody,

   What is the datatype in sql for storing  data from RichTextbox? How do I
create a sql Insert statement for this data? The data has format like
indentation, Butted list, Font Style and others.

Thanks.

Dennis
--
MCP Year 2005, Philippines

Author
31 Dec 2005 12:05 AM
Dan Guzman
The Rtf property of a RichTextbox is a string and this includes both data
and RTF formatting codes.  Consequently, you can use any character data
type.  The proper choice depends on whether you need to store unicode
characters, your maximum field length (including RTF codes) and the version
of SQL Server you are using.

The easiest way to perform the actual insert is with a parameterized insert
statement.  Untested example:

SqlCommand myInsertCommand = new SqlCommand(
    "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);

SqlParameter rtfParameter = new SqlParameter("@RtfValue",
SqlDbType.NVarChar);

myInsertCommand.Parameters.Add(rtfParameter);

rtfParameter.Value = myRichTextbox.Rtf;

myInsertCommand.ExecuteNonQuery();

--
Happy Holidays

Dan Guzman
SQL Server MVP

Show quote
"den 2005" <den2***@discussions.microsoft.com> wrote in message
news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> Hi everybody,
>
>   What is the datatype in sql for storing  data from RichTextbox? How do I
> create a sql Insert statement for this data? The data has format like
> indentation, Butted list, Font Style and others.
>
> Thanks.
>
> Dennis
> --
> MCP Year 2005, Philippines
Author
31 Dec 2005 2:43 AM
den 2005
Thanks Dan,

My data process is the not where is my GUI forms are, what data type should
I store the myRichTextbox.Rtf value to? and then transfer it to my dll for
actual databse insert.

I should use the datatype in sql for the column is nVarChar would be adequate?

I would try it.

dennis

--
MCP Year 2005, Philippines


Show quote
"Dan Guzman" wrote:

> The Rtf property of a RichTextbox is a string and this includes both data
> and RTF formatting codes.  Consequently, you can use any character data
> type.  The proper choice depends on whether you need to store unicode
> characters, your maximum field length (including RTF codes) and the version
> of SQL Server you are using.
>
> The easiest way to perform the actual insert is with a parameterized insert
> statement.  Untested example:
>
> SqlCommand myInsertCommand = new SqlCommand(
>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
>
> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
> SqlDbType.NVarChar);
>
> myInsertCommand.Parameters.Add(rtfParameter);
>
> rtfParameter.Value = myRichTextbox.Rtf;
>
> myInsertCommand.ExecuteNonQuery();
>
> --
> Happy Holidays
>
> Dan Guzman
> SQL Server MVP
>
> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> > Hi everybody,
> >
> >   What is the datatype in sql for storing  data from RichTextbox? How do I
> > create a sql Insert statement for this data? The data has format like
> > indentation, Butted list, Font Style and others.
> >
> > Thanks.
> >
> > Dennis
> > --
> > MCP Year 2005, Philippines
>
>
>
Author
31 Dec 2005 5:39 AM
Dan Guzman
Regardless of where you data layer resides, you are storing a string value.
In SQL 2000, an nvarchar max column length is 4000 characters so nvarchar
may be appropriate if your data doesn't exceed that length.  You could use
varchar (8000 max) if you do not need Unicode.

If your max data length is longer, you can use ntext or text in SQL 2000 or
nvarchar(MAX) or varchar(MAX) in SQL 2005.

--
Happy Holidays

Dan Guzman
SQL Server MVP

Show quote
"den 2005" <den2***@discussions.microsoft.com> wrote in message
news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
> Thanks Dan,
>
> My data process is the not where is my GUI forms are, what data type
> should
> I store the myRichTextbox.Rtf value to? and then transfer it to my dll for
> actual databse insert.
>
> I should use the datatype in sql for the column is nVarChar would be
> adequate?
>
> I would try it.
>
> dennis
>
> --
> MCP Year 2005, Philippines
>
>
> "Dan Guzman" wrote:
>
>> The Rtf property of a RichTextbox is a string and this includes both data
>> and RTF formatting codes.  Consequently, you can use any character data
>> type.  The proper choice depends on whether you need to store unicode
>> characters, your maximum field length (including RTF codes) and the
>> version
>> of SQL Server you are using.
>>
>> The easiest way to perform the actual insert is with a parameterized
>> insert
>> statement.  Untested example:
>>
>> SqlCommand myInsertCommand = new SqlCommand(
>>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
>>
>> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
>> SqlDbType.NVarChar);
>>
>> myInsertCommand.Parameters.Add(rtfParameter);
>>
>> rtfParameter.Value = myRichTextbox.Rtf;
>>
>> myInsertCommand.ExecuteNonQuery();
>>
>> --
>> Happy Holidays
>>
>> Dan Guzman
>> SQL Server MVP
>>
>> "den 2005" <den2***@discussions.microsoft.com> wrote in message
>> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
>> > Hi everybody,
>> >
>> >   What is the datatype in sql for storing  data from RichTextbox? How
>> > do I
>> > create a sql Insert statement for this data? The data has format like
>> > indentation, Butted list, Font Style and others.
>> >
>> > Thanks.
>> >
>> > Dennis
>> > --
>> > MCP Year 2005, Philippines
>>
>>
>>
Author
2 Jan 2006 9:17 AM
TryingforMVP
Hi den2005,
You can use text Datatype. Actually one of our app generate stored proc
code. so, we stored that code in text data type filed .
I hope this also helps as an alternative soln..
--
SQL SERVER DBA


Show quote
"Dan Guzman" wrote:

> Regardless of where you data layer resides, you are storing a string value.
> In SQL 2000, an nvarchar max column length is 4000 characters so nvarchar
> may be appropriate if your data doesn't exceed that length.  You could use
> varchar (8000 max) if you do not need Unicode.
>
> If your max data length is longer, you can use ntext or text in SQL 2000 or
> nvarchar(MAX) or varchar(MAX) in SQL 2005.
>
> --
> Happy Holidays
>
> Dan Guzman
> SQL Server MVP
>
> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
> > Thanks Dan,
> >
> > My data process is the not where is my GUI forms are, what data type
> > should
> > I store the myRichTextbox.Rtf value to? and then transfer it to my dll for
> > actual databse insert.
> >
> > I should use the datatype in sql for the column is nVarChar would be
> > adequate?
> >
> > I would try it.
> >
> > dennis
> >
> > --
> > MCP Year 2005, Philippines
> >
> >
> > "Dan Guzman" wrote:
> >
> >> The Rtf property of a RichTextbox is a string and this includes both data
> >> and RTF formatting codes.  Consequently, you can use any character data
> >> type.  The proper choice depends on whether you need to store unicode
> >> characters, your maximum field length (including RTF codes) and the
> >> version
> >> of SQL Server you are using.
> >>
> >> The easiest way to perform the actual insert is with a parameterized
> >> insert
> >> statement.  Untested example:
> >>
> >> SqlCommand myInsertCommand = new SqlCommand(
> >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
> >>
> >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
> >> SqlDbType.NVarChar);
> >>
> >> myInsertCommand.Parameters.Add(rtfParameter);
> >>
> >> rtfParameter.Value = myRichTextbox.Rtf;
> >>
> >> myInsertCommand.ExecuteNonQuery();
> >>
> >> --
> >> Happy Holidays
> >>
> >> Dan Guzman
> >> SQL Server MVP
> >>
> >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> >> > Hi everybody,
> >> >
> >> >   What is the datatype in sql for storing  data from RichTextbox? How
> >> > do I
> >> > create a sql Insert statement for this data? The data has format like
> >> > indentation, Butted list, Font Style and others.
> >> >
> >> > Thanks.
> >> >
> >> > Dennis
> >> > --
> >> > MCP Year 2005, Philippines
> >>
> >>
> >>
>
>
>
Author
3 Jan 2006 11:21 PM
den 2005
Thanks for replying , Dan and TryinfForMVP.

I used nText as datatype to store the data from a RichTextBox and it works
but not exactly store the exact format. Example, There is part of sentence
which should be indented but when I redisplay them, they are not. I used same
control to display them, since there is no other control can do this. Is
there another control?

den2005

--
MCP Year 2005, Philippines


Show quote
"TryingforMVP" wrote:

> Hi den2005,
> You can use text Datatype. Actually one of our app generate stored proc
> code. so, we stored that code in text data type filed .
> I hope this also helps as an alternative soln..
> --
> SQL SERVER DBA
>
>
> "Dan Guzman" wrote:
>
> > Regardless of where you data layer resides, you are storing a string value.
> > In SQL 2000, an nvarchar max column length is 4000 characters so nvarchar
> > may be appropriate if your data doesn't exceed that length.  You could use
> > varchar (8000 max) if you do not need Unicode.
> >
> > If your max data length is longer, you can use ntext or text in SQL 2000 or
> > nvarchar(MAX) or varchar(MAX) in SQL 2005.
> >
> > --
> > Happy Holidays
> >
> > Dan Guzman
> > SQL Server MVP
> >
> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
> > news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
> > > Thanks Dan,
> > >
> > > My data process is the not where is my GUI forms are, what data type
> > > should
> > > I store the myRichTextbox.Rtf value to? and then transfer it to my dll for
> > > actual databse insert.
> > >
> > > I should use the datatype in sql for the column is nVarChar would be
> > > adequate?
> > >
> > > I would try it.
> > >
> > > dennis
> > >
> > > --
> > > MCP Year 2005, Philippines
> > >
> > >
> > > "Dan Guzman" wrote:
> > >
> > >> The Rtf property of a RichTextbox is a string and this includes both data
> > >> and RTF formatting codes.  Consequently, you can use any character data
> > >> type.  The proper choice depends on whether you need to store unicode
> > >> characters, your maximum field length (including RTF codes) and the
> > >> version
> > >> of SQL Server you are using.
> > >>
> > >> The easiest way to perform the actual insert is with a parameterized
> > >> insert
> > >> statement.  Untested example:
> > >>
> > >> SqlCommand myInsertCommand = new SqlCommand(
> > >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
> > >>
> > >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
> > >> SqlDbType.NVarChar);
> > >>
> > >> myInsertCommand.Parameters.Add(rtfParameter);
> > >>
> > >> rtfParameter.Value = myRichTextbox.Rtf;
> > >>
> > >> myInsertCommand.ExecuteNonQuery();
> > >>
> > >> --
> > >> Happy Holidays
> > >>
> > >> Dan Guzman
> > >> SQL Server MVP
> > >>
> > >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> > >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> > >> > Hi everybody,
> > >> >
> > >> >   What is the datatype in sql for storing  data from RichTextbox? How
> > >> > do I
> > >> > create a sql Insert statement for this data? The data has format like
> > >> > indentation, Butted list, Font Style and others.
> > >> >
> > >> > Thanks.
> > >> >
> > >> > Dennis
> > >> > --
> > >> > MCP Year 2005, Philippines
> > >>
> > >>
> > >>
> >
> >
> >
Author
4 Jan 2006 12:22 AM
Dan Guzman
Are you storing data from the RichTextBox.Rtf property?  In that case, I
would expect this to work without loss of formatting.

Although this might not be a SQL issue, I'll try to help you out.  Can you
post an example problem RTF string as it was stored in the database?

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"den 2005" <den2***@discussions.microsoft.com> wrote in message
news:CA7C384E-DD3B-4F45-812E-F991700C78D6@microsoft.com...
> Thanks for replying , Dan and TryinfForMVP.
>
> I used nText as datatype to store the data from a RichTextBox and it works
> but not exactly store the exact format. Example, There is part of sentence
> which should be indented but when I redisplay them, they are not. I used
> same
> control to display them, since there is no other control can do this. Is
> there another control?
>
> den2005
>
> --
> MCP Year 2005, Philippines
>
>
> "TryingforMVP" wrote:
>
>> Hi den2005,
>> You can use text Datatype. Actually one of our app generate stored proc
>> code. so, we stored that code in text data type filed .
>> I hope this also helps as an alternative soln..
>> --
>> SQL SERVER DBA
>>
>>
>> "Dan Guzman" wrote:
>>
>> > Regardless of where you data layer resides, you are storing a string
>> > value.
>> > In SQL 2000, an nvarchar max column length is 4000 characters so
>> > nvarchar
>> > may be appropriate if your data doesn't exceed that length.  You could
>> > use
>> > varchar (8000 max) if you do not need Unicode.
>> >
>> > If your max data length is longer, you can use ntext or text in SQL
>> > 2000 or
>> > nvarchar(MAX) or varchar(MAX) in SQL 2005.
>> >
>> > --
>> > Happy Holidays
>> >
>> > Dan Guzman
>> > SQL Server MVP
>> >
>> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
>> > news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
>> > > Thanks Dan,
>> > >
>> > > My data process is the not where is my GUI forms are, what data type
>> > > should
>> > > I store the myRichTextbox.Rtf value to? and then transfer it to my
>> > > dll for
>> > > actual databse insert.
>> > >
>> > > I should use the datatype in sql for the column is nVarChar would be
>> > > adequate?
>> > >
>> > > I would try it.
>> > >
>> > > dennis
>> > >
>> > > --
>> > > MCP Year 2005, Philippines
>> > >
>> > >
>> > > "Dan Guzman" wrote:
>> > >
>> > >> The Rtf property of a RichTextbox is a string and this includes both
>> > >> data
>> > >> and RTF formatting codes.  Consequently, you can use any character
>> > >> data
>> > >> type.  The proper choice depends on whether you need to store
>> > >> unicode
>> > >> characters, your maximum field length (including RTF codes) and the
>> > >> version
>> > >> of SQL Server you are using.
>> > >>
>> > >> The easiest way to perform the actual insert is with a parameterized
>> > >> insert
>> > >> statement.  Untested example:
>> > >>
>> > >> SqlCommand myInsertCommand = new SqlCommand(
>> > >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
>> > >>
>> > >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
>> > >> SqlDbType.NVarChar);
>> > >>
>> > >> myInsertCommand.Parameters.Add(rtfParameter);
>> > >>
>> > >> rtfParameter.Value = myRichTextbox.Rtf;
>> > >>
>> > >> myInsertCommand.ExecuteNonQuery();
>> > >>
>> > >> --
>> > >> Happy Holidays
>> > >>
>> > >> Dan Guzman
>> > >> SQL Server MVP
>> > >>
>> > >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
>> > >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
>> > >> > Hi everybody,
>> > >> >
>> > >> >   What is the datatype in sql for storing  data from RichTextbox?
>> > >> > How
>> > >> > do I
>> > >> > create a sql Insert statement for this data? The data has format
>> > >> > like
>> > >> > indentation, Butted list, Font Style and others.
>> > >> >
>> > >> > Thanks.
>> > >> >
>> > >> > Dennis
>> > >> > --
>> > >> > MCP Year 2005, Philippines
>> > >>
>> > >>
>> > >>
>> >
>> >
>> >
Author
8 Jan 2006 11:19 PM
den 2005
Thanks for replying Dan.

Basically, the format in Richtextbox 'Entry' is this:

August 12, 2005    I am here typing showing sample to you and do not know
why    
                           when I stored this data it displays it
differently expecting to be
                           display the same,  especially when I am using
same control to
                           store and display them.

When displayed after getting data from database:

August 12, 2005    I am here typing showing sample to you and do not know
why    
                           when I stored this data it displays it
differently expecting to be
display
                           the same,  especially when I am using same
control to store and
                           display them.

dennis

--
MCP Year 2005, Philippines


Show quote
"Dan Guzman" wrote:

> Are you storing data from the RichTextBox.Rtf property?  In that case, I
> would expect this to work without loss of formatting.
>
> Although this might not be a SQL issue, I'll try to help you out.  Can you
> post an example problem RTF string as it was stored in the database?
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> news:CA7C384E-DD3B-4F45-812E-F991700C78D6@microsoft.com...
> > Thanks for replying , Dan and TryinfForMVP.
> >
> > I used nText as datatype to store the data from a RichTextBox and it works
> > but not exactly store the exact format. Example, There is part of sentence
> > which should be indented but when I redisplay them, they are not. I used
> > same
> > control to display them, since there is no other control can do this. Is
> > there another control?
> >
> > den2005
> >
> > --
> > MCP Year 2005, Philippines
> >
> >
> > "TryingforMVP" wrote:
> >
> >> Hi den2005,
> >> You can use text Datatype. Actually one of our app generate stored proc
> >> code. so, we stored that code in text data type filed .
> >> I hope this also helps as an alternative soln..
> >> --
> >> SQL SERVER DBA
> >>
> >>
> >> "Dan Guzman" wrote:
> >>
> >> > Regardless of where you data layer resides, you are storing a string
> >> > value.
> >> > In SQL 2000, an nvarchar max column length is 4000 characters so
> >> > nvarchar
> >> > may be appropriate if your data doesn't exceed that length.  You could
> >> > use
> >> > varchar (8000 max) if you do not need Unicode.
> >> >
> >> > If your max data length is longer, you can use ntext or text in SQL
> >> > 2000 or
> >> > nvarchar(MAX) or varchar(MAX) in SQL 2005.
> >> >
> >> > --
> >> > Happy Holidays
> >> >
> >> > Dan Guzman
> >> > SQL Server MVP
> >> >
> >> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
> >> > news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
> >> > > Thanks Dan,
> >> > >
> >> > > My data process is the not where is my GUI forms are, what data type
> >> > > should
> >> > > I store the myRichTextbox.Rtf value to? and then transfer it to my
> >> > > dll for
> >> > > actual databse insert.
> >> > >
> >> > > I should use the datatype in sql for the column is nVarChar would be
> >> > > adequate?
> >> > >
> >> > > I would try it.
> >> > >
> >> > > dennis
> >> > >
> >> > > --
> >> > > MCP Year 2005, Philippines
> >> > >
> >> > >
> >> > > "Dan Guzman" wrote:
> >> > >
> >> > >> The Rtf property of a RichTextbox is a string and this includes both
> >> > >> data
> >> > >> and RTF formatting codes.  Consequently, you can use any character
> >> > >> data
> >> > >> type.  The proper choice depends on whether you need to store
> >> > >> unicode
> >> > >> characters, your maximum field length (including RTF codes) and the
> >> > >> version
> >> > >> of SQL Server you are using.
> >> > >>
> >> > >> The easiest way to perform the actual insert is with a parameterized
> >> > >> insert
> >> > >> statement.  Untested example:
> >> > >>
> >> > >> SqlCommand myInsertCommand = new SqlCommand(
> >> > >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
> >> > >>
> >> > >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
> >> > >> SqlDbType.NVarChar);
> >> > >>
> >> > >> myInsertCommand.Parameters.Add(rtfParameter);
> >> > >>
> >> > >> rtfParameter.Value = myRichTextbox.Rtf;
> >> > >>
> >> > >> myInsertCommand.ExecuteNonQuery();
> >> > >>
> >> > >> --
> >> > >> Happy Holidays
> >> > >>
> >> > >> Dan Guzman
> >> > >> SQL Server MVP
> >> > >>
> >> > >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> >> > >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> >> > >> > Hi everybody,
> >> > >> >
> >> > >> >   What is the datatype in sql for storing  data from RichTextbox?
> >> > >> > How
> >> > >> > do I
> >> > >> > create a sql Insert statement for this data? The data has format
> >> > >> > like
> >> > >> > indentation, Butted list, Font Style and others.
> >> > >> >
> >> > >> > Thanks.
> >> > >> >
> >> > >> > Dennis
> >> > >> > --
> >> > >> > MCP Year 2005, Philippines
> >> > >>
> >> > >>
> >> > >>
> >> >
> >> >
> >> >
>
>
>
Author
8 Jan 2006 11:27 PM
den 2005
The data is not display as I want it to be.

The general idea is the right side paragraph of words is indented and some
words in thsi paragraph is not indented.

dennis
--
MCP Year 2005, Philippines


Show quote
"den 2005" wrote:

> Thanks for replying Dan.
>
> Basically, the format in Richtextbox 'Entry' is this:

> August 12, 2005    I am here typing showing sample to you and do not know
> why    
>                            when I stored this data it displays it
> differently expecting to be
>                            display the same,  especially when I am using
> same control to
>                            store and display them.
>
> When displayed after getting data from database:
>
> August 12, 2005    I am here typing showing sample to you and do not know
> why    
>                            when I stored this data it displays it
> differently expecting to be
> display
>                            the same,  especially when I am using same
> control to store and
>                            display them.
>
> dennis
>
> --
> MCP Year 2005, Philippines
>
>
> "Dan Guzman" wrote:
>
> > Are you storing data from the RichTextBox.Rtf property?  In that case, I
> > would expect this to work without loss of formatting.
> >
> > Although this might not be a SQL issue, I'll try to help you out.  Can you
> > post an example problem RTF string as it was stored in the database?
> >
> > --
> > Hope this helps.
> >
> > Dan Guzman
> > SQL Server MVP
> >
> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
> > news:CA7C384E-DD3B-4F45-812E-F991700C78D6@microsoft.com...
> > > Thanks for replying , Dan and TryinfForMVP.
> > >
> > > I used nText as datatype to store the data from a RichTextBox and it works
> > > but not exactly store the exact format. Example, There is part of sentence
> > > which should be indented but when I redisplay them, they are not. I used
> > > same
> > > control to display them, since there is no other control can do this. Is
> > > there another control?
> > >
> > > den2005
> > >
> > > --
> > > MCP Year 2005, Philippines
> > >
> > >
> > > "TryingforMVP" wrote:
> > >
> > >> Hi den2005,
> > >> You can use text Datatype. Actually one of our app generate stored proc
> > >> code. so, we stored that code in text data type filed .
> > >> I hope this also helps as an alternative soln..
> > >> --
> > >> SQL SERVER DBA
> > >>
> > >>
> > >> "Dan Guzman" wrote:
> > >>
> > >> > Regardless of where you data layer resides, you are storing a string
> > >> > value.
> > >> > In SQL 2000, an nvarchar max column length is 4000 characters so
> > >> > nvarchar
> > >> > may be appropriate if your data doesn't exceed that length.  You could
> > >> > use
> > >> > varchar (8000 max) if you do not need Unicode.
> > >> >
> > >> > If your max data length is longer, you can use ntext or text in SQL
> > >> > 2000 or
> > >> > nvarchar(MAX) or varchar(MAX) in SQL 2005.
> > >> >
> > >> > --
> > >> > Happy Holidays
> > >> >
> > >> > Dan Guzman
> > >> > SQL Server MVP
> > >> >
> > >> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
> > >> > news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
> > >> > > Thanks Dan,
> > >> > >
> > >> > > My data process is the not where is my GUI forms are, what data type
> > >> > > should
> > >> > > I store the myRichTextbox.Rtf value to? and then transfer it to my
> > >> > > dll for
> > >> > > actual databse insert.
> > >> > >
> > >> > > I should use the datatype in sql for the column is nVarChar would be
> > >> > > adequate?
> > >> > >
> > >> > > I would try it.
> > >> > >
> > >> > > dennis
> > >> > >
> > >> > > --
> > >> > > MCP Year 2005, Philippines
> > >> > >
> > >> > >
> > >> > > "Dan Guzman" wrote:
> > >> > >
> > >> > >> The Rtf property of a RichTextbox is a string and this includes both
> > >> > >> data
> > >> > >> and RTF formatting codes.  Consequently, you can use any character
> > >> > >> data
> > >> > >> type.  The proper choice depends on whether you need to store
> > >> > >> unicode
> > >> > >> characters, your maximum field length (including RTF codes) and the
> > >> > >> version
> > >> > >> of SQL Server you are using.
> > >> > >>
> > >> > >> The easiest way to perform the actual insert is with a parameterized
> > >> > >> insert
> > >> > >> statement.  Untested example:
> > >> > >>
> > >> > >> SqlCommand myInsertCommand = new SqlCommand(
> > >> > >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
> > >> > >>
> > >> > >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
> > >> > >> SqlDbType.NVarChar);
> > >> > >>
> > >> > >> myInsertCommand.Parameters.Add(rtfParameter);
> > >> > >>
> > >> > >> rtfParameter.Value = myRichTextbox.Rtf;
> > >> > >>
> > >> > >> myInsertCommand.ExecuteNonQuery();
> > >> > >>
> > >> > >> --
> > >> > >> Happy Holidays
> > >> > >>
> > >> > >> Dan Guzman
> > >> > >> SQL Server MVP
> > >> > >>
> > >> > >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> > >> > >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> > >> > >> > Hi everybody,
> > >> > >> >
> > >> > >> >   What is the datatype in sql for storing  data from RichTextbox?
> > >> > >> > How
> > >> > >> > do I
> > >> > >> > create a sql Insert statement for this data? The data has format
> > >> > >> > like
> > >> > >> > indentation, Butted list, Font Style and others.
> > >> > >> >
> > >> > >> > Thanks.
> > >> > >> >
> > >> > >> > Dennis
> > >> > >> > --
> > >> > >> > MCP Year 2005, Philippines
> > >> > >>
> > >> > >>
> > >> > >>
> > >> >
> > >> >
> > >> >
> >
> >
> >
Author
9 Jan 2006 12:59 AM
Dan Guzman
> The data is not display as I want it to be.

Yes, you can't reliably preserve text formatting in newsgroup posts.

I don't see any RTF formatting codes in the data you posted.  Can you post
the actual data as it is stored in the database?  I would expect to see RTF
formatting codes like /font, \tab, etc.

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"den 2005" <den2***@discussions.microsoft.com> wrote in message
news:A1556DD7-736F-4C48-B237-37985545B7FB@microsoft.com...
> The data is not display as I want it to be.
>
> The general idea is the right side paragraph of words is indented and some
> words in thsi paragraph is not indented.
>
> dennis
> --
> MCP Year 2005, Philippines
>
>
> "den 2005" wrote:
>
>> Thanks for replying Dan.
>>
>> Basically, the format in Richtextbox 'Entry' is this:
>>
>> August 12, 2005    I am here typing showing sample to you and do not know
>> why
>>                            when I stored this data it displays it
>> differently expecting to be
>>                            display the same,  especially when I am using
>> same control to
>>                            store and display them.
>>
>> When displayed after getting data from database:
>>
>> August 12, 2005    I am here typing showing sample to you and do not know
>> why
>>                            when I stored this data it displays it
>> differently expecting to be
>> display
>>                            the same,  especially when I am using same
>> control to store and
>>                            display them.
>>
>> dennis
>>
>> --
>> MCP Year 2005, Philippines
>>
>>
>> "Dan Guzman" wrote:
>>
>> > Are you storing data from the RichTextBox.Rtf property?  In that case,
>> > I
>> > would expect this to work without loss of formatting.
>> >
>> > Although this might not be a SQL issue, I'll try to help you out.  Can
>> > you
>> > post an example problem RTF string as it was stored in the database?
>> >
>> > --
>> > Hope this helps.
>> >
>> > Dan Guzman
>> > SQL Server MVP
>> >
>> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
>> > news:CA7C384E-DD3B-4F45-812E-F991700C78D6@microsoft.com...
>> > > Thanks for replying , Dan and TryinfForMVP.
>> > >
>> > > I used nText as datatype to store the data from a RichTextBox and it
>> > > works
>> > > but not exactly store the exact format. Example, There is part of
>> > > sentence
>> > > which should be indented but when I redisplay them, they are not. I
>> > > used
>> > > same
>> > > control to display them, since there is no other control can do this.
>> > > Is
>> > > there another control?
>> > >
>> > > den2005
>> > >
>> > > --
>> > > MCP Year 2005, Philippines
>> > >
>> > >
>> > > "TryingforMVP" wrote:
>> > >
>> > >> Hi den2005,
>> > >> You can use text Datatype. Actually one of our app generate stored
>> > >> proc
>> > >> code. so, we stored that code in text data type filed .
>> > >> I hope this also helps as an alternative soln..
>> > >> --
>> > >> SQL SERVER DBA
>> > >>
>> > >>
>> > >> "Dan Guzman" wrote:
>> > >>
>> > >> > Regardless of where you data layer resides, you are storing a
>> > >> > string
>> > >> > value.
>> > >> > In SQL 2000, an nvarchar max column length is 4000 characters so
>> > >> > nvarchar
>> > >> > may be appropriate if your data doesn't exceed that length.  You
>> > >> > could
>> > >> > use
>> > >> > varchar (8000 max) if you do not need Unicode.
>> > >> >
>> > >> > If your max data length is longer, you can use ntext or text in
>> > >> > SQL
>> > >> > 2000 or
>> > >> > nvarchar(MAX) or varchar(MAX) in SQL 2005.
>> > >> >
>> > >> > --
>> > >> > Happy Holidays
>> > >> >
>> > >> > Dan Guzman
>> > >> > SQL Server MVP
>> > >> >
>> > >> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
>> > >> > news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
>> > >> > > Thanks Dan,
>> > >> > >
>> > >> > > My data process is the not where is my GUI forms are, what data
>> > >> > > type
>> > >> > > should
>> > >> > > I store the myRichTextbox.Rtf value to? and then transfer it to
>> > >> > > my
>> > >> > > dll for
>> > >> > > actual databse insert.
>> > >> > >
>> > >> > > I should use the datatype in sql for the column is nVarChar
>> > >> > > would be
>> > >> > > adequate?
>> > >> > >
>> > >> > > I would try it.
>> > >> > >
>> > >> > > dennis
>> > >> > >
>> > >> > > --
>> > >> > > MCP Year 2005, Philippines
>> > >> > >
>> > >> > >
>> > >> > > "Dan Guzman" wrote:
>> > >> > >
>> > >> > >> The Rtf property of a RichTextbox is a string and this includes
>> > >> > >> both
>> > >> > >> data
>> > >> > >> and RTF formatting codes.  Consequently, you can use any
>> > >> > >> character
>> > >> > >> data
>> > >> > >> type.  The proper choice depends on whether you need to store
>> > >> > >> unicode
>> > >> > >> characters, your maximum field length (including RTF codes) and
>> > >> > >> the
>> > >> > >> version
>> > >> > >> of SQL Server you are using.
>> > >> > >>
>> > >> > >> The easiest way to perform the actual insert is with a
>> > >> > >> parameterized
>> > >> > >> insert
>> > >> > >> statement.  Untested example:
>> > >> > >>
>> > >> > >> SqlCommand myInsertCommand = new SqlCommand(
>> > >> > >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
>> > >> > >>
>> > >> > >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
>> > >> > >> SqlDbType.NVarChar);
>> > >> > >>
>> > >> > >> myInsertCommand.Parameters.Add(rtfParameter);
>> > >> > >>
>> > >> > >> rtfParameter.Value = myRichTextbox.Rtf;
>> > >> > >>
>> > >> > >> myInsertCommand.ExecuteNonQuery();
>> > >> > >>
>> > >> > >> --
>> > >> > >> Happy Holidays
>> > >> > >>
>> > >> > >> Dan Guzman
>> > >> > >> SQL Server MVP
>> > >> > >>
>> > >> > >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
>> > >> > >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
>> > >> > >> > Hi everybody,
>> > >> > >> >
>> > >> > >> >   What is the datatype in sql for storing  data from
>> > >> > >> > RichTextbox?
>> > >> > >> > How
>> > >> > >> > do I
>> > >> > >> > create a sql Insert statement for this data? The data has
>> > >> > >> > format
>> > >> > >> > like
>> > >> > >> > indentation, Butted list, Font Style and others.
>> > >> > >> >
>> > >> > >> > Thanks.
>> > >> > >> >
>> > >> > >> > Dennis
>> > >> > >> > --
>> > >> > >> > MCP Year 2005, Philippines
>> > >> > >>
>> > >> > >>
>> > >> > >>
>> > >> >
>> > >> >
>> > >> >
>> >
>> >
>> >
Author
10 Jan 2006 11:11 PM
den 2005
Here is the data in rtf format:

RTF Data:

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fmodern\fprq1\fcharset0
Courier New;}{\f1\fswiss\fprq2\fcharset0 Arial;}{\f2\fnil\fcharset0 Microsoft
Sans Serif;}}

\viewkind4\uc1\pard\f0\fs20 9/18/2004    Dear God \par

             I am writing you this letter in trying to answer some of my
questions, I \par

             don\rquote t understand the position I am in, I wont to be
filled with your holy \par

             spirit, Lord whatever it takes I want to be spirit lead, I
don\rquote t just want to \par

             write these words I want to live the words I am writing God
please fill me \par

             with your spirit, I want to be like Steven, what ever the cost
for me with \par

             your Spirit. In act chapter 6 it tell us that no one could
stand upto his \par

             wisdom, or the spirit by whom, he spoke , this meant that
Stephen was put to \par

             death , \par

             Lord I want whatever you have in store for me, whatever the
cost, my heart \par

             tells me you would not ask for something I couldn\rquote t give
I don\rquote t want \par

             anything separating me from the destiny you have for me. I love
you GOD , \par

             6thankyou for dying on the cross for all my sins, Lord I wont
to confess to \par

             you know, last night when Jared woke up I thought Rachel could
look after him \par

             I was being selfish, I wont personal glory forgive me for that
I love you \par

             Jesus Amem\par

             \par

             Dear Daddy\par

             I  am writing this letter to you to help me  understand our
relationship \par

             better, I am a very selfish person and am not coping very well
with life at \par

             the moment I seem to  have everybody else solution to their
problems but \par

             don\rquote t see to have any to my own problems. The things I
am confused about is \par

             am I a bad father am I the father that you want me to be, I
need massive \par

             amount of help in this department and am really saying I feel
like a failure \par

             , I know I am sounding confusing sometimes it seems that our
relationship is \par

             the same that you don\rquote t here me and as I write this I am
thinking I only have \par

             time for you when it suits me and not all the time I am sorry
for this , I \par

             would love to be available to have a relationship with you all
the time and \par

             not just when it suits me I love you GOD even writing it down
seems so hollow \par

             and fake, at the moment I feel so far away from you , I
don\rquote t wont a \par

             relationship like that I wont to be in a relationship that is
two way so \par

             often my Christianity feels like a fake that I can say stuff
that I know what \par

             to say and don\rquote t actually know. I am trying to be honest
but even know I am \par

             writing stuff to make myself sound better and that is not what
I am trying to \par

             do I am not writing this to sound good but to work on my
relationship with \par

             you , I am desperate for you Lord I cant do anything without
you , I need a \par

             fresh touch of you I need you real in my life what does it mean
that you will \par

             give you son anything he asks I am asking for a closer
relationship with you \par

             no matter what the cost no matter what the cost , if it means
loosing all my\par

             (our) money then so be it please don\rquote t let it be my
father and father in laws \par

             and my brothers money as well. Lord I am serious about wonting
to spend more \par

             time with you I can do it today I can spend all morning with
you  I don\rquote t \par

             care I just wont our relationship to be right. Is this dual
purpose of what I \par

             am doing know bad for our relationship \par

\par

10/1/2005    \f1 Heavanly Father I am crying out to you today \f0\par

             It was an interesting game of golf today I started to realize
that I have a \par

             fair few problems , I don\rquote t wont to be insecure , I wont
to be secure In you. \par

             Help me get this right in my life, I don\rquote t wont to be
insecure it is choking \par

             me. Help me to be the person you designed me to be. Lord i wont
to do what \par

             ever it takes, help me look to you for security teach me where
to look . Lord \par

             i dont wont to be jealous of other people success, i dont wont
to feel \par

             responible for other people failures as well. I wont ot hand
them over to you \par

             . Amen\par

\par

10/17/2005   \f1 Dear God\f0\par

             \f1 can it be that Paul  understand that what i asked for on
Friday is not what i expected today,Lord i give this \par

                          to you\f0\par

             \f1 Lord I give you that the program is having all sorts of
problems today and that it wasn\rquote t actioned earlier\f0  \par

             \f1 Lord I give you impact Home sand the problems it has their
with IPR and Ross work\f0\par

             \f1 I am strugglerling with handing it over ot you the hours
the guys are wortking etc\'85..\f0\par

             \f1 Lord i need your help , help me hand it over to you \f0\par

\par

  \par

\f2\fs17\par

}




dennis
--
MCP Year 2005, Philippines


Show quote
"Dan Guzman" wrote:

> > The data is not display as I want it to be.
>
> Yes, you can't reliably preserve text formatting in newsgroup posts.
>
> I don't see any RTF formatting codes in the data you posted.  Can you post
> the actual data as it is stored in the database?  I would expect to see RTF
> formatting codes like /font, \tab, etc.
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> news:A1556DD7-736F-4C48-B237-37985545B7FB@microsoft.com...
> > The data is not display as I want it to be.
> >
> > The general idea is the right side paragraph of words is indented and some
> > words in thsi paragraph is not indented.
> >
> > dennis
> > --
> > MCP Year 2005, Philippines
> >
> >
> > "den 2005" wrote:
> >
> >> Thanks for replying Dan.
> >>
> >> Basically, the format in Richtextbox 'Entry' is this:
> >>
> >> August 12, 2005    I am here typing showing sample to you and do not know
> >> why
> >>                            when I stored this data it displays it
> >> differently expecting to be
> >>                            display the same,  especially when I am using
> >> same control to
> >>                            store and display them.
> >>
> >> When displayed after getting data from database:
> >>
> >> August 12, 2005    I am here typing showing sample to you and do not know
> >> why
> >>                            when I stored this data it displays it
> >> differently expecting to be
> >> display
> >>                            the same,  especially when I am using same
> >> control to store and
> >>                            display them.
> >>
> >> dennis
> >>
> >> --
> >> MCP Year 2005, Philippines
> >>
> >>
> >> "Dan Guzman" wrote:
> >>
> >> > Are you storing data from the RichTextBox.Rtf property?  In that case,
> >> > I
> >> > would expect this to work without loss of formatting.
> >> >
> >> > Although this might not be a SQL issue, I'll try to help you out.  Can
> >> > you
> >> > post an example problem RTF string as it was stored in the database?
> >> >
> >> > --
> >> > Hope this helps.
> >> >
> >> > Dan Guzman
> >> > SQL Server MVP
> >> >
> >> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
> >> > news:CA7C384E-DD3B-4F45-812E-F991700C78D6@microsoft.com...
> >> > > Thanks for replying , Dan and TryinfForMVP.
> >> > >
> >> > > I used nText as datatype to store the data from a RichTextBox and it
> >> > > works
> >> > > but not exactly store the exact format. Example, There is part of
> >> > > sentence
> >> > > which should be indented but when I redisplay them, they are not. I
> >> > > used
> >> > > same
> >> > > control to display them, since there is no other control can do this.
> >> > > Is
> >> > > there another control?
> >> > >
> >> > > den2005
> >> > >
> >> > > --
> >> > > MCP Year 2005, Philippines
> >> > >
> >> > >
> >> > > "TryingforMVP" wrote:
> >> > >
> >> > >> Hi den2005,
> >> > >> You can use text Datatype. Actually one of our app generate stored
> >> > >> proc
> >> > >> code. so, we stored that code in text data type filed .
> >> > >> I hope this also helps as an alternative soln..
> >> > >> --
> >> > >> SQL SERVER DBA
> >> > >>
> >> > >>
> >> > >> "Dan Guzman" wrote:
> >> > >>
> >> > >> > Regardless of where you data layer resides, you are storing a
> >> > >> > string
> >> > >> > value.
> >> > >> > In SQL 2000, an nvarchar max column length is 4000 characters so
> >> > >> > nvarchar
> >> > >> > may be appropriate if your data doesn't exceed that length.  You
> >> > >> > could
> >> > >> > use
> >> > >> > varchar (8000 max) if you do not need Unicode.
> >> > >> >
> >> > >> > If your max data length is longer, you can use ntext or text in
> >> > >> > SQL
> >> > >> > 2000 or
> >> > >> > nvarchar(MAX) or varchar(MAX) in SQL 2005.
> >> > >> >
> >> > >> > --
> >> > >> > Happy Holidays
> >> > >> >
> >> > >> > Dan Guzman
> >> > >> > SQL Server MVP
> >> > >> >
> >> > >> > "den 2005" <den2***@discussions.microsoft.com> wrote in message
> >> > >> > news:DD1E72E1-F9B8-40C3-B198-C7C926DBB763@microsoft.com...
> >> > >> > > Thanks Dan,
> >> > >> > >
> >> > >> > > My data process is the not where is my GUI forms are, what data
> >> > >> > > type
> >> > >> > > should
> >> > >> > > I store the myRichTextbox.Rtf value to? and then transfer it to
> >> > >> > > my
> >> > >> > > dll for
> >> > >> > > actual databse insert.
> >> > >> > >
> >> > >> > > I should use the datatype in sql for the column is nVarChar
> >> > >> > > would be
> >> > >> > > adequate?
> >> > >> > >
> >> > >> > > I would try it.
> >> > >> > >
> >> > >> > > dennis
> >> > >> > >
> >> > >> > > --
> >> > >> > > MCP Year 2005, Philippines
> >> > >> > >
> >> > >> > >
> >> > >> > > "Dan Guzman" wrote:
> >> > >> > >
> >> > >> > >> The Rtf property of a RichTextbox is a string and this includes
> >> > >> > >> both
> >> > >> > >> data
> >> > >> > >> and RTF formatting codes.  Consequently, you can use any
> >> > >> > >> character
> >> > >> > >> data
> >> > >> > >> type.  The proper choice depends on whether you need to store
> >> > >> > >> unicode
> >> > >> > >> characters, your maximum field length (including RTF codes) and
> >> > >> > >> the
> >> > >> > >> version
> >> > >> > >> of SQL Server you are using.
> >> > >> > >>
> >> > >> > >> The easiest way to perform the actual insert is with a
> >> > >> > >> parameterized
> >> > >> > >> insert
> >> > >> > >> statement.  Untested example:
> >> > >> > >>
> >> > >> > >> SqlCommand myInsertCommand = new SqlCommand(
> >> > >> > >>     "INSERT INTO MyTable VALUES(@RtfValue)" myConnection);
> >> > >> > >>
> >> > >> > >> SqlParameter rtfParameter = new SqlParameter("@RtfValue",
> >> > >> > >> SqlDbType.NVarChar);
> >> > >> > >>
> >> > >> > >> myInsertCommand.Parameters.Add(rtfParameter);
> >> > >> > >>
> >> > >> > >> rtfParameter.Value = myRichTextbox.Rtf;
> >> > >> > >>
> >> > >> > >> myInsertCommand.ExecuteNonQuery();
> >> > >> > >>
> >> > >> > >> --
> >> > >> > >> Happy Holidays
> >> > >> > >>
> >> > >> > >> Dan Guzman
> >> > >> > >> SQL Server MVP
> >> > >> > >>
> >> > >> > >> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> >> > >> > >> news:B6BDEA22-739F-4271-98B4-F9571DD55D0A@microsoft.com...
> >> > >> > >> > Hi everybody,
> >> > >> > >> >
> >> > >> > >> >   What is the datatype in sql for storing  data from
> >> > >> > >> > RichTextbox?
> >> > >> > >> > How
> >> > >> > >> > do I
> >> > >> > >> > create a sql Insert statement for this data? The data has
> >> > >> > >> > format
> >> > >> > >> > like
> >> > >> > >> > indentation, Butted list, Font Style and others.
> >> > >> > >> >
> >> > >> > >> > Thanks.
> >> > >> > >> >
> >> > >> > >> > Dennis
> >> > >> > >> > --
> >> > >> > >> > MCP Year 2005, Philippines
> >> > >> > >>
> >> > >> > >>
> >> > >> > >>
> >> > >> >
> >> > >> >
> >> > >> >
> >> >
> >> >
> >> >
>
>
>
Author
11 Jan 2006 3:30 AM
Dan Guzman
I inserted this value into a SQL ntext column, retrieved the value and
assigned it to the RichTextBox.Rtf property.  I had to set the
RichTextBox.WordWrap property to false to get the proper indenting, though.
Could that be your issue?

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"den 2005" <den2***@discussions.microsoft.com> wrote in message
news:48880EBC-F49B-4BFC-9C2C-D713FCB114C3@microsoft.com...
> Here is the data in rtf format:
>
Author
12 Jan 2006 11:52 PM
den 2005
Thanks Dan for the tip, it works. Pardon if it takes me for a while to reply.

dennis

--
MCP Year 2005, Philippines


Show quote
"Dan Guzman" wrote:

> I inserted this value into a SQL ntext column, retrieved the value and
> assigned it to the RichTextBox.Rtf property.  I had to set the
> RichTextBox.WordWrap property to false to get the proper indenting, though.
> Could that be your issue?
>
> --
> Hope this helps.
>
> Dan Guzman
> SQL Server MVP
>
> "den 2005" <den2***@discussions.microsoft.com> wrote in message
> news:48880EBC-F49B-4BFC-9C2C-D713FCB114C3@microsoft.com...
> > Here is the data in rtf format:
> >
>
>
>

AddThis Social Bookmark Button