|
I am using VB6 with MS access
If rs1.State = 1 Then
rs1.Close
End If
my control enter in if statement
but give error while closing
|
|
|
|
|
and error given is
Operation is not allowed in this context
|
|
|
|
|
Hiii
Use Rs1=Nothing
mai be is do same work and not throw any error.
Thanx
Mitesh Khatri
|
|
|
|
|
~Khatri Mitesh~ wrote: Use Rs1=Nothing
mai be is do same work and not throw any error.
No, it does not do the same work. Setting a reference to Nothing doesn't close the recordset, it only makes it unreachable.
It's imperative that all recordsets and connections are closed correctly, otherwise the connection to the database remains open until it times out.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Why are you checking the state of the recordset? If you don't know if the recordset is supposed to be open or not, that suggests that the code doesn't really have the firm control over the connections and recordsets that it ought to have.
Have you already closed the connection when this code runs? If you close the connection before the recordset, the recordset might be left in a state where it thinks that it's still connected, but it can't close correctly. You should close all recordsets before you close the connection.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You might have made changes to the record set without having committed or abandoned them.
In vb6, I believe setting a record set variable to nothing will force an immediate close, though it may generate an error if there are pending changes (the same case where a .close fails). I would consider such code to be very sloppy, however, and it would be likely to cause problems if the code is ported to vb.net.
I have had to work with code that never bothered to close record sets except when trying to reuse them. I see no reason ever to write such code(*), and I have no idea how such practices came into being. Is there some popular book that illustrated the 'global allocate/lazy close' technique? The code is more cumbersome than code which closes record sets when they are no longer needed; using local variables in VB6 or using blocks in VB.net will avoid problems even when connections are left open. So why the kludge?
(*)There are a few cases where it might make sense to leave a record set open even when a program is "idle", if the program needs to be able to respond quickly to asynchronous events. Even in such cases, however, the decision of when to close a connection would be made deliberately.
|
|
|
|
|
My complete code
On Error GoTo religionerror
Dim religion As String
religion = InputBox("Enter Religion", "Religion", "")
If rs1.State = 1 Then
rs1.Close
End If
rs1.Open "select * from religion", cn1, adOpenDynamic, adLockOptimistic
rs1.AddNew
rs1("religion") = religion
rs1.Update
rs1.Close
cmb_religion.AddItem religion
Exit Sub
religionerror:
If Not religion = "" Then
MsgBox "Relgion Already exists Or you Enter Nothing", vbInformation, "SMS WARNING"
End If
End Sub
Its working poperly
but when some error while updating then the code
If rs1.State = 1 Then
rs1.Close
End If
not working properly
|
|
|
|
|
Hi,
I am new to VB and VB.NET. My Application is upgraded from VB6 to VB.NET. But I got some problems as "Couldn't resolve default property of object Me.". How Can I resolve these kind of warnings. Here is my code:
Private ReadOnly Property IParameter_LeseLaenge() As Integer Implements _IParameter.LeseLaenge
Get
'UPGRADE_WARNING: Couldn't resolve default property of object Me. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Return I_IParameter(Me).laenge
End Get
End Property
//I_IParameter method is:
Public Function I_IParameter(ByRef obj As _IParameter) As _IParameter
I_IParameter = obj
End Function
One More:
Public WriteOnly Property SelButton() As System.Windows.Forms.Button
Set(ByVal Value As System.Windows.Forms.Button)
mSelBtn = Value
If mParent.IsAlive Then
'UPGRADE_WARNING: Couldn't resolve default property of object Me. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Parent.AddCtrl(mSelBtn, Me)
End If
End Set
End Property
//AddCtrl method:
Public Sub AddCtrl(ByVal ctrl As System.Windows.Forms.Control, ByVal descriptor As _IFieldDescriptor)
'UPGRADE_ISSUE: ObjPtr function is not supported. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'
mCtrls.Add(descriptor, CStr(ObjPtr(ctrl)))
End Sub
Could any one of you please let me the solution?
Thanks in Advance.
AR Reddy
|
|
|
|
|
In vb.net Me always refers to the current form... I think if u look ur code with this information u can find the issue
|
|
|
|
|
Thanks, Ill try it out.
AR Reddy
|
|
|
|
|
nishkarsh_k wrote: In vb.net Me always refers to the current form
Wrong, but I can see why you'd think this is true. Me always refers to the current instance of the class in which it is used. Since a Form is nothing but a class, Me works just like it is used in any other class code.
modified on Monday, June 30, 2008 12:37 PM
|
|
|
|
|
Hi thanks for the reply,
I am not able to get this. In VB6.0, passing a parameter as "ME", (means type is current class if I am not wrong). When we convert it to VB.NET this parameter is converting as ME only but waring message " Couldn't resolve default property of object Me." coming.
Here is the sample code.
VB6 code:
Private Property Get IParameter_SchreibLaenge() As Long
IParameter_SchreibLaenge = I_IParameter(Me).laenge
End Property
VB.NET Code:
Private ReadOnly Property IParameter_SchreibLaenge() As Integer Implements _IParameter.SchreibLaenge
Get
'UPGRADE_WARNING: Couldn't resolve default property of object Me. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Return I_IParameter(Me).laenge
End Get
End Property
Note: This is nto giving any compilation error. But Its giving runtime error. When we run it, its giving some cast error.
Please help me out. I am really struggling for this to get.
Thanks in Advance,
AR Reddy
|
|
|
|
|
Under VB.NET, there is no default property for the Me object. You have to specifically tell the compiler which property of Me you are referring to.
Private ReadOnly Property IParameter_SchreibLaenge() As Integer Implements _IParameter.SchreibLaenge
Get
'UPGRADE_WARNING: Couldn't resolve default property of object Me. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Return I_IParameter(Me.whichProperty).laenge
End Get
End Property
<div class="ForumSig"> <small>
<a href="http://www.codeproject.com/scrapbook/ForumGuidelines.asp">A guide to posting questions on CodeProject</a>[<a href="http://www.codeproject.com/scrapbook/ForumGuidelines.asp" target="_blank" title="New Window">^</a>]</small>
<br>
<font color="Blue">Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic<br /> 2006, 2007, 2008</font>
</br>
</div>
|
|
|
|
|
|
hii
i want to calculate NORMDIST function using dotnet.
it Returns the normal distribution for the specified mean and standard deviation. This function has a very wide range of applications in statistics, including hypothesis testing.
Syntax
NORMDIST(x,mean,standard_dev,cumulative)
For this Purpose I need integral from negative infinity to x of normal density function
i m using vb.net 2005
please help me.
|
|
|
|
|
I did a google and came up with this[^], does it help ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks 4 reply but it was not helpful.
Still I m unable to implement mathematics Integration in dot net
|
|
|
|
|
OK - well, there's nothing built in. The code I linked to, claimed to do it. So, if it didn't, then you need to write your own.
'
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
anyone have any idea of using a section inside a app.config? I am looking for any example regarding this area. Thanks.
|
|
|
|
|
How do you mean, just storing settings in there ? There's tons of examples on that. If you mean something else, please clarify.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ya.. storing settings in it and loop through the section for the desire result. Any link where by there is example to that area?
|
|
|
|
|
|
I have a string variable which contains the name of a textbox whose text I want to get/use.
How can I I create a textbox object from my variable and get the text?
Thanks!
-Steve
|
|
|
|
|
Reflection.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
If i didn't know how to phrase it for a forum, how would i know how to phrase it for a search engine? Useful keywords would have helped more than a post on how to use Google.
|
|
|
|