表格不会与rtb好玩 [英] Form won't play nice with rtb

查看:61
本文介绍了表格不会与rtb好玩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为Calendar的VB.NET程序。在顶部有一个菜单,

在日历之上打开另一个表单(如弹出框)。弹出的

框形式称为备忘录形式。这是一个独立的(没有与

第一格式通信)数据库表格,带有3个下拉框,一个关闭框。框和一个rtb。

我有这个工作(请参阅

microsoft.public.vb.database论坛中的将RTB内容保存到SQL Server)然后a用户开始抱怨

关于应用程序崩溃。在调查中我发现我无法b $ b可靠地重新创建问题,但是当用户在rtb控件中输入大量信息时,发现问题似乎发生了b $ b。所以,我试着用
来编写我的SaveMessage代码中的代码错误代码。程序,但

有趣的是,当它实际上试图保存数据时,代码没有错误(我在我建立的引用对象中执行的操作) ),或者当它通过代码将数据放入rtb时通过
。如果我单步执行代码

(没有错误捕获)它会让我一直到达我想要的结果,然后我点击F8最后一个子结束我认为接下来我会看到的是备忘录。表单,而是我得到一个未处理的

类型''System.NullReferenceException''...异常对象引用不是

设置为对象的实例。 ;错误及其停止的行是

" Public Class Calendar"来自日历的形成!!!我仍然可以看到我的

备忘录在前台形成,这是应该放弃的形式

我来。


我想出了让数据库对象返回一个" 1 QUOT;或者0

取决于数据是否正确保存到数据库,以及

似乎返回0或0。当我将长字符串放入rtb时,如果我插入代码来处理错误条件,我甚至还会得到对象

引用。最后的错误就像以前一样。


我能想到的是,这与rtb没有处理

的数据有关以某种方式破坏

表格上的实际rtb控制。当我的代码试图查看或清除它时,它不再存在,并且

将解释该消息。它还可以解释我的数据库对象

返回一个0。在这种情况下正确。我将SQL Server中的字段设置为二进制1000并将其设置为二进制1000。并扩展到2000年,但没有效果。


我希望这是足够的信息让你继续。这里有很多小东西,我几乎需要把代码寄给你。请看下面的代码

关于我如何执行某些任务的摘要。


我希望你能帮助我。


Schoo

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
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 "SaveMessage" 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.NullReferenceException''... 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

以下是我称之为备忘录的方法。来自日历:
=================

Private Sub MenuItem4_Click(ByVal ....)处理MenuItem4.Click

将备忘录作为备忘录=新备忘录

memos.show()

结束子

===== ============

这是对数据库对象的调用:
=================

昏暗响应为整数= oDBAccess.saveMessage(strCurMonth,strCurYear,

strCurType,rtb1)

========= ========

这是数据库对象中saveMessage函数的活动代码:
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.saveMessage(strCurMonth, strCurYear,
strCurType, rtb1)
=================
Here is the active code in the saveMessage function in the database object:



======== =========

尝试

如果GetRecsScalar(从每月消息中选择计数(*)

dtYear =" ;& dtYear&"和dtMonth ="& dtMonth&" and typeid =(select type

from type where type =''"& type&" '')")> 0然后

strSql =" update monthlymessages set message = @mess where

dtYear =" &安培; dtYear& "和dtMonth =" &安培; dtMonth& "和typeid =(选择id

来自type type =''"& type&"'')"

Else

strSql =" insert into monthlymessages select" &安培; dtYear& ",

" &安培; dtMonth& ",(从类型中选择id,其中type =''"& type&"''),@ mess"

结束如果


Dim rtf(999)As Byte

Dim s As New MemoryStream(rtf)

rtb.SaveFile(s,RichTextBoxStreamType.RichText)

Dim p(1)As SqlParameter

p(0)= New SqlParameter(" @ mess",SqlDbType.Binary,1000)

p(0).Value = rtf


Microsoft.ApplicationBlocks.Data.SqlHelper.Execute NonQuery(oSettings.dbConn,

CommandType.Text,strSql,p)

Catch

intResponse = 0

结束尝试

返回intResponse

========== =======


=================
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(rtf)
rtb.SaveFile(s, RichTextBoxStreamType.RichText)
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@mess", SqlDbType.Binary, 1000)
p(0).Value = rtf

Microsoft.ApplicationBlocks.Data.SqlHelper.Execute NonQuery(oSettings.dbConn,
CommandType.Text, strSql, p)
Catch
intResponse = 0
End Try
Return intResponse
=================

推荐答案




从代码看来一切都好,你能提供一个简单的重现

样本。

您可以尝试将SaveFile保存到磁盘目录并使用相同的步骤来查看

如果那将重现问题,这将有助于我们隔离t他是

问题。


你也可以尝试增加缓冲区的数量。

例如数据库字段是2000,

更改下面的代码。

rrf到1999

p(0)到2000.


Dim rtf(999)As Byte

Dim s As New MemoryStream(rtf)

rtb.SaveFile(s,RichTextBoxStreamType.RichText)

Dim p(1)As SqlParameter

p(0)= New SqlParameter(" @ mess",SqlDbType.Binary,1000)

p(0) .Value = rtf


祝你好运,

Peter Huang

Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有授予任何权利。

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(rtf)
rtb.SaveFile(s, RichTextBoxStreamType.RichText)
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@mess", SqlDbType.Binary, 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.





从代码中看来一切都还行,你能提供一个简单的重现

样本。

您可以尝试将SaveFile保存到磁盘目录并使用相同的步骤来查看

if这将重现问题,这将有助于我们隔离

问题。


您也可以尝试增加缓冲区的数量。

例如数据库字段是2000,

更改下面的代码。

rrf到1999

p(0)到2000.


Dim rtf(999)As Byte

Dim s As New MemoryStream(rtf)

rtb.SaveFile(s,RichTextBoxStreamType.RichText)

Dim p(1)As SqlParameter

p(0)= New SqlParameter(" @ mess",SqlDbType.Binary,1000)

p(0) .Value = rtf


祝你好运,

Peter Huang

Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有授予任何权利。

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(rtf)
rtb.SaveFile(s, RichTextBoxStreamType.RichText)
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@mess", SqlDbType.Binary, 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.


[我已经通过您的电子邮件地址直接将参考文件发送给您。

以下是与之相关的信息:]


彼得,


感谢您试图帮助我。我对我的

saveMessage和getMessage程序进行了一些更改(在那里添加了1000个值),并且

虽然它似乎让我更进一步,它仍然崩溃

应用程序就像以前一样。我知道我对

二进制对象和rtb / rtf概念知之甚少。有没有一个很好的解释(网站

网站),我可以查看,以帮助我更好地了解msdn或

的东西? ...最好是技术性较差,我能理解

很快。


无论如何,我要转发整个项目给你审查,请

请参阅随附的zip文件。以下是对附件的解释:


1)zip文件中有一个名为OnCall.bak的文件。这是SQL数据库的备份



2)访问MonthlyMessages的表单。 table被称为Memos.vb。

将其设置为运行测试的第一个表单。

3)OnCallDB.DBAccess.vb file包含使用的数据库访问代码

byMemos.vb

4)在运行之前,修改OnCallDB.DBAccess.vb。文件与您的

数据库访问设置。我正在使用SQL Server2000


整个项目的工作原理除了这个功能,用户正在进行Beta测试

现在。一旦这项工作,我们将在全公司范围内发布!没有压力或

任何东西。 :)我将在周末离开,可能不会再回到你身边

直到星期一。我期待听到你能找到的东西,并告诉我。
告诉我。祝你好运。


Schoo :)


"" Peter Huang"" <,V - ****** @ online.microsoft.com>在留言中写道

news:mq ************** @ cpmsftngxa10.phx.gbl ...
[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 "MonthlyMessages" table is called "Memos.vb".
Set that as the first form to run for your testing.
3) The "OnCallDB.DBAccess.vb" file contains the database access code used
by "Memos.vb"
4) Before running, modify the "OnCallDB.DBAccess.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.microsoft.com> wrote in message
news:mq**************@cpmsftngxa10.phx.gbl...


从代码看来一切都还可以,你能提供一个简单的重现样本。
你可以尝试将SaveFile保存到磁盘目录并使用相同的步骤来
见如果这将重现问题,这将有助于我们隔离
问题。

您也可以尝试增加缓冲区的数量。
例如数据库字段是2000,
更改下面的代码。
rrf到1999
p(0)到2000.

Dim rtf(999)As Byte
rtb.SaveFile(s,RichTextBoxStreamType.RichText)
Dim p(1)As SqlParameter
p(0)= New SqlParameter(" @ mess,SqlDbType.Binary,1000)
p(0).Value = rtf

致以最好的问候,

Peter Huang
微软在线合作伙伴支持

获得安全! - www.microsoft.com/security
此帖子提供按原样没有保证,也没有
权利。
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(rtf)
rtb.SaveFile(s, RichTextBoxStreamType.RichText)
Dim p(1) As SqlParameter
p(0) = New SqlParameter("@mess", SqlDbType.Binary, 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.



这篇关于表格不会与rtb好玩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆