473,774 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form won't play nice with rtb

I have a VB.NET program called "Calendar" that has a menu on the top that
opens up another form (like a pop-up box) on top of "Calendar". The pop-up
box form is called "Memos" which is a stand-alone (doesn't communicate with
first form) database form with 3 drop-down boxes, a "Close" box and a rtb.
I had this working (see "Saving RTB content to SQL Server" in the
microsoft.publi c.vb.database forum) and then a user started to complain
about application crashes. On investigation I found that I couldn't
recreate the issue reliably but noticed that the problem seemed to occur
when the user typed alot of information into the rtb control. So, I tried
to write error code around the code in my "SaveMessag e" procedure, but the
funny thing is that the code doesn't error when it actually tries to save
the data (which I am doing in a referenced object I built), or when it goes
through the code to put the data in the rtb. If I step through the code
(without the error trapping) it makes it all the way to what I would expect
to be the end, and then I hit F8 at the last "Sub End" line thinking the
next thing I will see is the "Memos" form and instead I get an "unhandled
exception of type 'System.NullRef erenceException '... Object reference not
set to an instance of an object." error and the line it is stopping on is
"Public Class Calendar" from the "Calendar" form!!! I can still see my
"Memos" form in the fore-ground and that is the form it should have dropped
me to.

I came up with the idea of having thedatabase object return a "1" or "0"
depending on whether the data saved to the database correctly, and that
seems to return the "0" when I put in the long string into the rtb, but even
if I insert code to deal with the error condition, I still get the "Object
reference" error at the end just like before.

All I can think of is that this has something to do with the rtb not dealing
with the data properly and somehow destroying the actual rtb control on the
form. When my code tries to view it or clear it, it is no longer there and
that would explain the message. It would also explain my database object
returning a "0" properly in this instance. I had the field in SQL Server
set to "binary 1000" and expanded that to 2000, but no effect.

I hope that is enough info for you to go on. There are so many little
things here I almost need to send you the code. Look below for code
snippets of how I am performing certain tasks.

I hope you can help me.

Schoo
Here is how I call "Memos" from "Calendar": =============== ==
Private Sub MenuItem4_Click (ByVal....) Handles MenuItem4.Click
Dim memos as memos = New Memos
memos.show()
End Sub
=============== ==
Here is the call to the database object: =============== ==
Dim response as integer = oDBAccess.saveM essage(strCurMo nth, strCurYear,
strCurType, rtb1)
=============== ==
Here is the active code in the saveMessage function in the database object:

=============== ==
Try
If GetRecsScalar(" select count(*) from monthlymessages where
dtYear = " & dtYear & " and dtMonth = " & dtMonth & " and typeid=(select id
from type where type = '" & type & "')") > 0 Then
strSql = "update monthlymessages set message = @mess where
dtYear = " & dtYear & " and dtMonth = " & dtMonth & " and typeid=(select id
from type where type = '" & type & "')"
Else
strSql = "insert into monthlymessages select " & dtYear & ",
" & dtMonth & ", (select id from type where type = '" & type & "'), @mess"
End If

Dim rtf(999) As Byte
Dim s As New MemoryStream(rt f)
rtb.SaveFile(s, RichTextBoxStre amType.RichText )
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@ mess", SqlDbType.Binar y, 1000)
p(0).Value = rtf

Microsoft.Appli cationBlocks.Da ta.SqlHelper.Ex ecuteNonQuery(o Settings.dbConn ,
CommandType.Tex t, strSql, p)
Catch
intResponse = 0
End Try
Return intResponse
=============== ==

Nov 21 '05 #1
13 1332
Hi

From the code it seems that all is OK, can you provide a simple reproduce
sample.
You may try to SaveFile to the disk directory and use the same steps to see
if that will reproduce the problem which will help us to isolate the
problem.

Also you may try to increase of the count of the buffer.
e.g. the database field is 2000,
change the code below.
rrf to 1999
p(0) to 2000.

Dim rtf(999) As Byte
Dim s As New MemoryStream(rt f)
rtb.SaveFile(s, RichTextBoxStre amType.RichText )
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@ mess", SqlDbType.Binar y, 1000)
p(0).Value = rtf

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2
Hi

From the code it seems that all is OK, can you provide a simple reproduce
sample.
You may try to SaveFile to the disk directory and use the same steps to see
if that will reproduce the problem which will help us to isolate the
problem.

Also you may try to increase of the count of the buffer.
e.g. the database field is 2000,
change the code below.
rrf to 1999
p(0) to 2000.

Dim rtf(999) As Byte
Dim s As New MemoryStream(rt f)
rtb.SaveFile(s, RichTextBoxStre amType.RichText )
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@ mess", SqlDbType.Binar y, 1000)
p(0).Value = rtf

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #3
[I have sent the referenced file to you directly via your email address.
Here is the message to go along with it:]

Peter,

Thank you for trying to help me with this. I made some changes to my
saveMessage and getMessage procedures (adding 1000 to the values there), and
while it seems to let me get a little further, it still crashes the
application just like before. I recognize that I know very little about
binary objects and rtb/rtf concepts. Is there a good explaination (web
site) that I can review to help me understand this better on msdn or
something? ... preferably something less technical that I can understand
quickly.

Anyway, I am going to forward the whole project for you to review, please
see the attached zip file. Here is an explaination of the attached file:

1) There is a file in the zip file called "OnCall.bak ". This is a backup
of the SQL Database.
2) The form that accesses the "MonthlyMessage s" table is called "Memos.vb".
Set that as the first form to run for your testing.
3) The "OnCallDB.DBAcc ess.vb" file contains the database access code used
by "Memos.vb"
4) Before running, modify the "OnCallDB.DBAcc ess.vb" file with your
database access settings. I am using SQL Server2000

The whole project works except for this feature and users are Beta testing
it now. As soon as this works we release company-wide! No pressure or
anything. :) I am leaving for the weekend and may not get back to you
until Monday. I look forward to hearing about what you are able to find and
tell me. Good luck.

Schoo :)

""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:mq******** ******@cpmsftng xa10.phx.gbl...
Hi

From the code it seems that all is OK, can you provide a simple reproduce
sample.
You may try to SaveFile to the disk directory and use the same steps to see if that will reproduce the problem which will help us to isolate the
problem.

Also you may try to increase of the count of the buffer.
e.g. the database field is 2000,
change the code below.
rrf to 1999
p(0) to 2000.

Dim rtf(999) As Byte
Dim s As New MemoryStream(rt f)
rtb.SaveFile(s, RichTextBoxStre amType.RichText )
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@ mess", SqlDbType.Binar y, 1000)
p(0).Value = rtf

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #4
Peter,

I tried sending this to you at v-******@online.m icrosoft.com but it came
back. Please confirm your email or please provide another way I can get
this to you.

Schoo

""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:mq******** ******@cpmsftng xa10.phx.gbl...
Hi

From the code it seems that all is OK, can you provide a simple reproduce
sample.
You may try to SaveFile to the disk directory and use the same steps to see if that will reproduce the problem which will help us to isolate the
problem.

Also you may try to increase of the count of the buffer.
e.g. the database field is 2000,
change the code below.
rrf to 1999
p(0) to 2000.

Dim rtf(999) As Byte
Dim s As New MemoryStream(rt f)
rtb.SaveFile(s, RichTextBoxStre amType.RichText )
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@ mess", SqlDbType.Binar y, 1000)
p(0).Value = rtf

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #5
Hi Scott,

You can reach Peter by email at the address you tried, just remove "online"
from it.

Brett Keown
Microsoft Support
br*****@online. microsoft.com

This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #6
Hi Scott,

As Brett said, you may reach me by removing the "online" from my email
address.
I am sorry for the inconvenience and I will be appreciate if you can resend
the email.
Thanks!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #7
OK, I have just resent the file to v-******@microsof t.com

BTW: if you know of any good articles explaining rtb controls or binary
objects, let me know.

Schoo
""Peter Huang"" <v-******@online.m icrosoft.com> wrote in message
news:bK******** *****@cpmsftngx a10.phx.gbl...
Hi Scott,

As Brett said, you may reach me by removing the "online" from my email
address.
I am sorry for the inconvenience and I will be appreciate if you can resend the email.
Thanks!

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #8
Hi Scott,

I have received the attachment.
But there is no OnCallDB.DBAcce ss.vb in the zip file.
Can you resend the whole package to me?

Also I think you may also try to stored the whole richtextbox.rtf property
to a string and then add the string to the sqlserver.
You may use the System.Text.Uni codeEncoding class's GetBytes method to
encode that into a byte array.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #9
Hi Scott,

It is strange that I have tried your code but I can not reproduce the
problem, the project runs well on my side and it will save the data correct
without any exception.
The only one I think you may try to add it that since you have define the
size of the binary field in the sql server, we would better to detect the
length of the rtf file so that there will have no error.

I think you may try to get the property below.
rtb.rtf.length, we need to make sure it is less than the binary field, if
large we need to pop up a messagebox tell the enduser the rtb has too many
text.

So far I think we would better try to the code on another machine to see if
the problem persist.

Saving Files with the Windows Forms RichTextBox Control
http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtsksavingfile withwindowsform srichtextboxcon trol.asp
Create a Graphical Editor Using RichTextBox and GDI+
http://msdn.microsoft.com/msdnmag/is...dvancedBasics/

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #10

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

Similar topics

16
12929
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine otherwise. Most interesting to me is that a reboot won't fix the problem. But if I just try it again sometime later it will work. Anyone have any ideas? I'm running python 2.3 on windows 2000 professional.
4
2151
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see "TAG#") when more than 1 number (see "VLANS") is inputed into my form. QUESTION: How do I make my dynamic form have a dynamic input box(which is created by checking the checkbox and calling the functionC1) inside it and still be able to pass the...
1
1299
by: cbell | last post by:
I would like javascript file (which can be a .js file) which I can use to play .wav files on demand. there are many pages and there will only be ONE .wav file (about 20 seconds) for each page. the form table to go onto the page will have graphics (not form buttons) for: - play/pause - stop - volume >> I will design the buttons later, the form doesn't have to be fancy - it just has to work with graphic buttons.
3
3261
by: iam247 | last post by:
Hi I have an asp page without any javascript. It posts the content of a form to another page, which reads the form fields using Request.Form. This is the form header: <form name=form method=post action=RegDetails.asp> I have tried to modify the form by adding javascript for password
4
2316
by: Mason | last post by:
This is probably an incredibly newbie-ish question. I just haven't had the cause to use many subforms before, so I'm pretty sure I just don't understand it correctly (even after reading up on it). I have a relationship set up that is used to track the hours an employee has worked on each project during the week. I'm trying to set up a Form to allow someone to choose their name and a Period Ending date (basically, the tblTimeReport...
0
752
by: Schoo | last post by:
I have a VB.NET program called "Calendar" that has a menu on the top that opens up another form (like a pop-up box) on top of "Calendar". The pop-up box form is called "Memos" which is a stand-alone (doesn't communicate with first form) database form with 3 drop-down boxes, a "Close" box and a rtb. I had this working (see "Saving RTB content to SQL Server" in the microsoft.public.vb.database forum) and then a user started to complain...
6
1910
by: drec | last post by:
I am just learning Javascript and I would like to create a basic form that gives me two options. This will be using either checkbox or radio input type, however I would like the second option to allow the user to type in a value. Also, I would like the 2nd option only editable if the button for that option is selected. All I can seem to find is basic examples of forms, and none of which have this feature. The form would look something...
4
304
by: Alan T | last post by:
How do I create a form inherited from an existing form in the same project ?
4
8748
by: Deano | last post by:
I'm in the situation of having to print a form - not a report. This will fit nicely in a landscape format but by default it prints portrait. Is there any code to make it play nice?
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.