|
I think you may be running into problems on this specific function cmd.ExecuteScalar() . I need to know what data its trying to pull. Try puting a breakpoint on the line and executing it. When it stops at that line open up the immediate window (down by your output for compilation) and type into it
?GetAllChangeControl
It would be good if it said NULL or Nothing, which I am sure it will sense it dies at that point. Does Visual Studios give you the key dropdown after you type cmd.? If it doesn't that is where the problem would be. I'm just throwing out a list of ideas here, try the debugging with the immediate window and let me know what the output of it is.
~ Mike
|
|
|
|
|
Try the following with your function:
Public Function GetAllChangeControl() As String
Dim con As OleDbConnection
Dim cmd As OleDbCommand = New OleDbCommand
con = New OleDbConnection(connectionstring)
cmd.Connection = con
cmd.CommandText = "EXECUTE GetAllChangeControl"
con.Open()
'---------------------------------------------
' Here is the change
Dim retVal As Object
Try
retVal = cmd.ExecuteScalar()
If Not(IsNothing(retVal)) Then
Return Cstr(retVal)
Else
Return String.Empty
End If
Catch ex As OledbException
Throw ex
Finally
con.Close()
If Not con Is Nothing Then con.Dispose
If Not cmd Is Nothing Then cmd.Dispose
End Try
'------------------------------------------
End Function
Let me explain, it is possible that your "cmd.ExecuteScalar" is not returning anything and you are not checking for that, so what I've done here is do a simple check and return the appropriate value. I have also enclosed the procedure in a Try statement to capture the Exception, and make sure that even if an Exception is thrown, the connection is closed and you realease your resources.
I hope this helps.
|
|
|
|
|
I would like to be able to click on the drop down arrow. Pick the date and once I click it should show the date in a seperate text box.
Does anyone know the code for that.
Any help would be appreciated.
Thanks.
|
|
|
|
|
Handle the DateTimePicker's ValueChanged event. Get the Value from your DateTimePicker control, convert it to a String in the format you want and set the Text property of your TextBox.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks Dave,
How do I put all this in code language.
I am sorry for being so dumb but I am new to VB.Net and just want to get over with this stupid project.
Please help!
|
|
|
|
|
shakizil wrote: I am new to VB.Net and just want to get over with this stupid project.
Why does this scream "HOMEWORK ASSIGNMENT"???
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: Why does this scream "HOMEWORK ASSIGNMENT"???
Don't look the people in that way. I usually meet this problem. I don't have any home work from school. But sometime i have my own idea to build an application, sometime i have an idea to do it but don't know how to code it.
|
|
|
|
|
Roath Kanel wrote: But sometime i have my own idea to build an application,
I seriously doubt that's the case here, simply because of this one statement he made:
...just want to get over with this stupid project.
This is telling me it's something he doesn't want to do. The only thing that fits his profile of a newbie and an assignment he/she doesn't want is homework.
I, and many people here, will not write someones homework assignment for them. That's what RentACoder is for! We'll help with code that is already written, but won't write it for them.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Originally yes, the first reply is correct, although another alternative would be to set the textbox.text property value. Say for instance you have a text box named txtbxdate and a date & time picker named datetm. You would need to set the code of the text box to equal the date selected from the date & time drop down. It would look something like this
txtbxdate.text = datetm.selecteddate
or something like that I'm not actually running visual studios so I don't know exactly what the date & time picker property looks like but i know you can set the text of a text box to the date & time selected on the date & time box.
~ Mike
|
|
|
|
|
Never mind. I got it.
Its only a one line code that takes care of the problem.
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged<br />
Me.txttrgdt.Text = Me.DateTimePicker1.Value.ToString("MM/dd/yyyy")<br />
End Sub
There you go guys.
And Dave this is not a HOME WORK ASSIGNMENT.
Thanks.
|
|
|
|
|
Hi,
What is the correct way of determining whether or not (part of) a control is visible on the screen? (i.e. when graphics in the control is continuously being updated, requiring a lot of processing that you'd want to save if the control is not even visible (when its parent window is minimized or overlapped by other windows, etc.)
Thanks
Jim
|
|
|
|
|
If Windows wants the control redrawn, it'll tell you. You don't have to worry about redrawing if you don't get a Paint message. What you might want to do is check to make sure your controls Visible property is set and not paint your control if it's false.
Simply, if your control is not visible, Windows won't send you any Paint messages, even if Invalidate is called on your control. No Paint messages means your control won't paint until Windows determines that your control has, at least, a tiny bit of it visible.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks, but I am talking about the situation when I (not Windows) want to have it redrawn because I want to change its contents, not because it needs repainting. (so there won't be any Paint event).
|
|
|
|
|
Well, the only other method you have is redrawing on a Timer event. In the tick, you Invalidate your own control. Then you'll get the Paint event sent to you, IF any part of your control is visible.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks. My application is multithreaded so I wont need the timer event. However, your answer reminded me that I should use Invalidate and the Paint event instead of directly calling redrawing functions!
Thanks again
|
|
|
|
|
I have a small program in vb.net that until today worked perfectly. All i did was change some icons (form icons and the program icon) and recompile . Now i am seeing some odd behavior and cant figure out why. The program still works perfectly when run from the IDE (VS2003) but the built exe generates an error which i can trap. The other odd thing is that the file size of the exe has dropped from 567kb to 450kb.
Any ideas?
Jon
|
|
|
|
|
jonathan15 wrote: but the built exe generates an error
And that would be ______________________________??
Without that, it's pretty impossible to tell you anything useful. The code that generated the error would also help.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The error is "Object reference not set to an instance of an object. at In_Sync.frmMain.StartMe() in C:\Visual Studio Projects\In-Sync2\In-Sync\Forms\Form1.vb:line 229" which i log in the event log.
This relates to this section of code:
For Each parkToChange In setupDetail.Parks
SetAvail(parkToChange.ParkCode)
Next
Setupdetail.parks is a shared property so in form1 this is not instanced it is simply called. Of course in setupdetail an instance of the 'Parks' object is created and populated with 'Park' Items as in this next bit of code (setupdetail.loadvalues).
Dim myparks As parks = New parks
If Not mFirstRun Then
Do While secureReader.Read
Dim mypark As park = New park(secureReader.GetString(1), crypto.Decrypt(secureReader.GetString(3)), secureReader.GetString(0))
myparks.Add(mypark)
Loop
Else
Form1 is set as the startup object and should call Setupdetail.loadvalues before calling the startme rutine which is generating the error. As in the code below:
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
setupDetail.LoadValues()
StartMe()
'Add any initialization after the InitializeComponent() call
End Sub
The thing is it all works when run through the IDE so debugging is not possible. I have tried to log events at key stages and found that Setupdetail.loadevents is never entered. So that is why i get the error because setupdetail.parks does not exist. My real question is why is it never run. Could the form be corrupted.
Jon
|
|
|
|
|
Let me get this straight:
Public Class Form1
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
setupDetail.LoadValues()
StartMe()
'Add any initialization after the InitializeComponent() call
End Sub
Public Sub StartMe()
For Each parkToChange In setupDetail.Parks
SetAvail(parkToChange.ParkCode)
Next
End Sub
End Class
Public Class setupDetail
Public Shared Property
blah, blah, blah
End Property
Public Shared LoadValues()
Dim myparks As parks = New parks
If Not mFirstRun Then
Do While secureReader.Read
Dim mypark As park = New park(secureReader.GetString(1), _
crypto.Decrypt(secureReader.GetString(3)), secureReader.GetString(0))
myparks.Add(mypark)
Loop
Else
...
End If
End Sub
End Class
Is this about correct?
Why is this setupDetail class using all Shared stuff? What you're doing would be much better off as a normal class where all the methods to populate and manipulate the Parks collection are public, not shared. Everything you're doing is manipulating public data from outside the class that contains it. This is a no-no according to normal OOP practices.
I'd rewrite your Parks collection into its own class, supplying public methods to initialize itself and manipulate the collection and its data. You can then create an instance of this class, even follow the Singleton Pattern[^] to create a globally single instance of it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Yep, I accept that this isnt the best way to do things and when i planned it there were only 2 shared properties in this class and 1 shared method to get the data. It does need redoing but at the moment it works so im not going to touch it.
With regard to the initial problem, i rebuilt the application by opening a new project and adding the existing files (except form1) then re-created form1 from scratch. Guess what, It works.
Thanks for your help though. I appreciate you spending the time to look at it for me.
Thanks
Jonathan
|
|
|
|
|
jonathan15 wrote: It does need redoing but at the moment it works so im not going to touch it.
jonathan15 wrote: With regard to the initial problem, i rebuilt the application by opening a new project and adding the existing files (except form1) then re-created form1 from scratch. Guess what, It works.
If you needed to do this to get it to work again, you need to rebuild the class quicker than your think. Is what you did to get it to work again a supportable solution? I don't think so. I think you're living on borrowed time now. I'd be rewriting this thing first thing in the morning so any future changes to the code don't break it again.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Just Tested it some more and it is definately not entering setupdetail.loadvalues when run from the exe but it is when run through the IDE. This happens even if i move the call from sub new to the start of startme routine.
Why would it do this?
Jon
|
|
|
|
|
Hi,
I'm using vs.net 2003, and i want to make a program for the smartphone,what i want is just a simple window that contains a command button for exiting the program, and if i push the "X" (that is available on the upper right side for the pocket pc screen) the program will not be closed but the window will be hide and a small button will appear on the today screen that can i move it wherever i want, and i want to return to the program if i push this button.
Im using visual basic.net
Thanks
Smart
|
|
|
|
|
SmartSDR wrote: Who can do this ??????
Are you asking if someone here will write this for you?? Not going to happen... It's not what we're here for.
If you've got a specific question about a coding problem you're having, by all means, ask away! But, please, be specific when explaining the problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I'm asking how to make this? i don't know how to make it.
I didn't make any program for the pocket pc.
And i need someone to help me to make this cause i want to make a dictionary for the pocket pc.
Thanks
Smart
|
|
|
|