Solved

Rich Text Box not reading data back from mysql database

Posted on 2004-08-12
9
409 Views
Last Modified: 2008-02-01
Ok, working with the Rich Text Box. I can successfully save data from the box to the database field (largetext field in mysql). The problem is I can't get it back out!  When I set the rich text box = the field it's blank.

HELP!!!
0
Comment
Question by:digitalwav
9 Comments
 
LVL 1

Expert Comment

by:kanithi
ID: 11786286
Can you post the sample code so that we can look at whats wrong.
0
 
LVL 1

Author Comment

by:digitalwav
ID: 11786336
Ok, this routine is what I'm using for reading/writing to the tables:


Select Case SubAction

Case "Read"
rs.Open "SELECT * FROM rma WHERE id='" & vbalGrid2.CellText(iRow, 6) & "'", conn, adOpenStatic, adLockOptimistic
rs.Requery

If IsNull(rs!rma_rmanum) = False Then Text16.Text = rs!rma_rmanum Else Text16.Text = ""
If IsNull(rs!rma_dateissued) = False Then Text17.Text = rs!rma_dateissued Else Text17.Text = ""
If IsNull(rs!rma_dateshipped) = False Then Text18.Text = rs!rma_dateshipped Else Text18.Text = ""
If IsNull(rs!rma_dateclosed) = False Then Text19.Text = rs!rma_dateclosed Else Text19.Text = ""
If IsNull(rs!rma_cmsemployee) = False Then Text20.Text = rs!rma_cmsemployee Else Text20.Text = ""
If IsNull(rs!rma_serialnum) = False Then Text21.Text = rs!rma_serialnum Else Text21.Text = ""
If IsNull(rs!rma_cmspo) = False Then Text22.Text = rs!rma_cmspo Else Text22.Text = ""
If IsNull(rs!rma_creditamt) = False Then Text23.Text = rs!rma_creditamt Else Text23.Text = ""
If IsNull(rs!rma_customerpo) = False Then Text24.Text = rs!rma_customerpo Else Text24.Text = ""
If IsNull(rs!rma_closed) = False Then Check3.Value = rs!rma_closed Else Check3.Value = 0
If IsNull(rs!rma_warranty) = False Then Check4.Value = rs!rma_warranty Else Check4.Value = 0
If IsNull(rs!rma_creditissued) = False Then Check5.Value = rs!rma_creditissued Else Check5.Value = 0
If IsNull(rs!rma_billablerepair) = False Then Check6.Value = rs!rma_billablerepair Else Check6.Value = 0
If IsNull(rs!rma_partnum) = False Then Combo2.Text = rs!rma_partnum Else Combo2.Text = ""
If IsNull(rs!rma_returnedpartgoes) = False Then Combo3.Text = rs!rma_returnedpartgoes Else Combo3.Text = ""
If IsNull(rs!rma_problem) = False Then RichTextBox2.TextRTF = rs!rma_problem Else RichTextBox2.TextRTF = ""
If IsNull(rs!rma_comments) = False Then RichTextBox3.TextRTF = rs!rma_comments Else RichTextBox3.TextRTF = ""
Text25.Text = rs!ID
rs.Close

Case "Write"


rs.Open "SELECT * FROM rma WHERE id='" & Text25.Text & "'", conn, adOpenStatic, adLockOptimistic ' WHERE id='" & Text25.Text & "'
'Select Case Command2.Enabled
'Case True
'rs.Requery
'rs.MoveFirst
'Case False
'rs.AddNew
'rs.Fields("rma_contactid") = Text15.Text
'End Select

If Text16.Text <> "" Then rs.Fields("rma_rmanum") = Text16.Text Else
If Text17.Text <> "" Then rs.Fields("rma_dateissued") = Text17.Text Else
If Text18.Text <> "" Then rs.Fields("rma_dateshipped") = Text18.Text Else
If Text19.Text = "" Then rs.Fields("rma_dateclosed") = Null Else rs!rma_dateclosed = Text19.Text
If Text20.Text <> "" Then rs.Fields("rma_cmsemployee") = Text20.Text Else
If Text21.Text <> "" Then rs.Fields("rma_serialnum") = Text21.Text Else
If Text22.Text <> "" Then rs.Fields("rma_cmspo") = Text22.Text Else
If Text23.Text <> "" Then rs.Fields("rma_creditamt") = Text23.Text Else
If Text24.Text <> "" Then rs.Fields("rma_customerpo") = Text24.Text Else
If Combo2.Text <> "" Then rs.Fields("rma_partnum") = Combo2.Text Else
If Combo3.Text <> "" Then rs.Fields("rma_returnedpartgoes") = Combo3.Text Else
'If RichTextBox2.TextRTF <> "" Then rs.Fields("rma_problem") = RichTextBox2.TextRTF Else
'If RichTextBox3.TextRTF <> "" Then rs.Fields("rma_comments") = RichTextBox3.TextRTF Else
rs.Fields("rma_closed") = Check3.Value
rs.Fields("rma_warranty") = Check4.Value
rs.Fields("rma_creditissued") = Check5.Value
rs.Fields("rma_billablerepair") = Check6.Value
rs.Update
rs.Close

Case "Clear"
Text16.Text = ""
Text17.Text = ""
Text18.Text = ""
Text19.Text = ""
Text20.Text = ""
Text21.Text = ""
Text22.Text = ""
Text23.Text = ""
Text24.Text = ""
Combo2.Text = ""
Combo3.Text = ""
RichTextBox2.Text = ""
RichTextBox3.Text = ""
Check3.Value = 0
Check4.Value = 0
Check5.Value = 0
Check6.Value = 0
Text25.Text = ""
Case Else

End Select
0
 
LVL 1

Expert Comment

by:kanithi
ID: 11786952
OK,

So your porblem is while reading its not reading into the text box properly.
Try using Text property of RichTextBox instead of TextRTF.

Let me know
0
 
LVL 1

Author Comment

by:digitalwav
ID: 11787105
Tried that, same result. Also tried not specifying like this richtextbox2=rs!somefield
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 12

Expert Comment

by:BobLamberson
ID: 11790678
Hi digitalwav,
Assume you have checked the simple stuff like
    is the recordset really returning a value,
    and do you get a result when you evaluate the rs!somefield in the immediate window,
    and can you set the richtextbox to the value in the immediate window?
You might need to set a variable to the value of a field, then set the value of richtextbox to the variable.

Bob
0
 
LVL 1

Expert Comment

by:HolliStt
ID: 11803754
Please paste as the result of

debug.print rs!somefield

I am using RTF Fields alot but with the Access (Jet) Database. But I don't know what mySQL does with it. How do you save it?

I have checked my own programs I always have to do it that way

SAVING:

rs!somefield = richtextbox1

LOADING:

richttextbox = rs!somefield

0
 
LVL 1

Author Comment

by:digitalwav
ID: 11851046
This is what I ended up doing. The RTF data was being saved in the database. I could see it with an SQL exploring app.  But this is the code I found that worked for reading it back:

If RichTextBox2.TextRTF <> "" Then Adodc2.Recordset.Fields("rma_problem") = RichTextBox2.TextRTF Else
If RichTextBox2.Text <> "" Then Adodc2.Recordset.Fields("rma_probpreview") = Left$(RichTextBox2.Text, 200) Else

0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12208275
PAQed, with points refunded (500)

Computer101
E-E Admin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now