J
JC - home
Hello..
I've been having some problems for a little while with this which I was
sure I would beat...hmmm.
Anyway, I have a form with two rich textboxes. One at the top which is
to display a concatenated summary, and one at the botton for making a
new entry.
When items are added in from the bottom box, I do this via a class
(call_detail.vb):
code from the click event of the submit button
------------------------------------------------
Dim mycall_detail As New call_detail
mycall_detail.reference = update_reference
mycall_detail.narrative = SpellCheckRichText1.Rtf.ToString
mycall_detail.add_narrative()
-------------------------------------------------
I then call the add_narrative function as so from the class
----------------------------------------
Public Function add_narrative()
Dim sqlcom As New SqlCommand
sqlcom.Connection = sqlcon
sqlcom.CommandType = CommandType.StoredProcedure
sqlcom.CommandText = "add_narrative"
sqlcom.Parameters.Add("@in_call_reference", reference)
sqlcom.Parameters.Add("@in_narrative", narrative)
sqlcom.Parameters.Add("@in_user", System.Environment.UserName)
If sqlcon.State <> ConnectionState.Open Then sqlcon.Open()
sqlcom.ExecuteNonQuery()
End Function
----------------------------------------
This calls a SQL Stored proc: as so
------------------------------------------
dbo.add_narrative
@in_call_reference int,
@in_narrative text,
@in_user char(40)
AS
insert into call_details(
call_reference,narrative,entered_by,date_entered)
values(@in_call_reference,@in_narrative,@in_user,getdate()
----------------------------------------------
This seems to add the data into the narrative table fine. one of the
entries in the narrative.narrative field contains:
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang2057\deflangfe2057{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose
02020603050405020304}Times New Roman;} test
This is the output from the rtf.tostring of the lower rich text box.
I can read that data back into a string no problem, but getting it to
show as formatted rich text is where I'm having problems - it only ever
displays literally.
I use a function in my class called_populate memo:
---------------------------------------------
Public Function populate_memo()
' Lets use a sqldata reader to get our text properties!!!
Dim retval As String
Dim sqlcom As New SqlCommand
sqlcom.Connection = sqlcon
sqlcom.CommandType = CommandType.StoredProcedure
sqlcom.CommandText = "get_verbose_narratives"
sqlcom.Parameters.Add("@in_call", reference)
Dim narr_reader As SqlDataReader
If sqlcon.State <> ConnectionState.Open Then sqlcon.Open()
narr_reader = sqlcom.ExecuteReader
C_memo = Nothing
While narr_reader.Read
memo += Trim(narr_reader.GetString(2)) & " on " &
narr_reader.GetDateTime(1) & vbNewLine
memo += "----------------------------------------------" &
vbNewLine
memo += narr_reader.GetString(0)
memo += vbNewLine & vbNewLine
End While
End Function
-------------------------------------------------
This calls the following stored procedure:
---------------------------------------
dbo.get_verbose_narratives
@in_call int
as
SELECT narrative,date_entered, entered_by
FROM call_details
WHERE (call_reference = @in_call)
ORDER BY narrative_id
--------------------------------------------
And finally here is the code I use when trying to pass the contents of
the "memo" property of my class into the upper rich text box.
------------------------------------------
Dim mycalldetail As New call_detail
mycalldetail.reference = update_reference
mycalldetail.populate_memo()
MessageBox.Show(mycalldetail.memo)
RichTextBox1.AppendText(mycalldetail.memo)
--------------------------------------------
I'm presuming this is a cast / type issue of sorts as if I create a
richtext document called jc.rtf and call :
' RichTextBox1.LoadFile("d:\jc.rtf")
instead of the appendtext line it works fine.
I toyed with the idea of creating temporary richtext files to read
from, but don't like that idea at all...
I know this is all a little vague, but can anyone throw any light on
this? Am I making a fundemental error?
Many Thanks![Smile :) :)](/styles/default/custom/smilies/smile.gif)
JC
I've been having some problems for a little while with this which I was
sure I would beat...hmmm.
Anyway, I have a form with two rich textboxes. One at the top which is
to display a concatenated summary, and one at the botton for making a
new entry.
When items are added in from the bottom box, I do this via a class
(call_detail.vb):
code from the click event of the submit button
------------------------------------------------
Dim mycall_detail As New call_detail
mycall_detail.reference = update_reference
mycall_detail.narrative = SpellCheckRichText1.Rtf.ToString
mycall_detail.add_narrative()
-------------------------------------------------
I then call the add_narrative function as so from the class
----------------------------------------
Public Function add_narrative()
Dim sqlcom As New SqlCommand
sqlcom.Connection = sqlcon
sqlcom.CommandType = CommandType.StoredProcedure
sqlcom.CommandText = "add_narrative"
sqlcom.Parameters.Add("@in_call_reference", reference)
sqlcom.Parameters.Add("@in_narrative", narrative)
sqlcom.Parameters.Add("@in_user", System.Environment.UserName)
If sqlcon.State <> ConnectionState.Open Then sqlcon.Open()
sqlcom.ExecuteNonQuery()
End Function
----------------------------------------
This calls a SQL Stored proc: as so
------------------------------------------
dbo.add_narrative
@in_call_reference int,
@in_narrative text,
@in_user char(40)
AS
insert into call_details(
call_reference,narrative,entered_by,date_entered)
values(@in_call_reference,@in_narrative,@in_user,getdate()
----------------------------------------------
This seems to add the data into the narrative table fine. one of the
entries in the narrative.narrative field contains:
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang2057\deflangfe2057{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose
02020603050405020304}Times New Roman;} test
This is the output from the rtf.tostring of the lower rich text box.
I can read that data back into a string no problem, but getting it to
show as formatted rich text is where I'm having problems - it only ever
displays literally.
I use a function in my class called_populate memo:
---------------------------------------------
Public Function populate_memo()
' Lets use a sqldata reader to get our text properties!!!
Dim retval As String
Dim sqlcom As New SqlCommand
sqlcom.Connection = sqlcon
sqlcom.CommandType = CommandType.StoredProcedure
sqlcom.CommandText = "get_verbose_narratives"
sqlcom.Parameters.Add("@in_call", reference)
Dim narr_reader As SqlDataReader
If sqlcon.State <> ConnectionState.Open Then sqlcon.Open()
narr_reader = sqlcom.ExecuteReader
C_memo = Nothing
While narr_reader.Read
memo += Trim(narr_reader.GetString(2)) & " on " &
narr_reader.GetDateTime(1) & vbNewLine
memo += "----------------------------------------------" &
vbNewLine
memo += narr_reader.GetString(0)
memo += vbNewLine & vbNewLine
End While
End Function
-------------------------------------------------
This calls the following stored procedure:
---------------------------------------
dbo.get_verbose_narratives
@in_call int
as
SELECT narrative,date_entered, entered_by
FROM call_details
WHERE (call_reference = @in_call)
ORDER BY narrative_id
--------------------------------------------
And finally here is the code I use when trying to pass the contents of
the "memo" property of my class into the upper rich text box.
------------------------------------------
Dim mycalldetail As New call_detail
mycalldetail.reference = update_reference
mycalldetail.populate_memo()
MessageBox.Show(mycalldetail.memo)
RichTextBox1.AppendText(mycalldetail.memo)
--------------------------------------------
I'm presuming this is a cast / type issue of sorts as if I create a
richtext document called jc.rtf and call :
' RichTextBox1.LoadFile("d:\jc.rtf")
instead of the appendtext line it works fine.
I toyed with the idea of creating temporary richtext files to read
from, but don't like that idea at all...
I know this is all a little vague, but can anyone throw any light on
this? Am I making a fundemental error?
Many Thanks
![Smile :) :)](/styles/default/custom/smilies/smile.gif)
JC