|
You should not attempt to remove items from a collection when performing a For Each through the same collection. Use a For loop to traverse the collection in reverse order, removing the items as you go.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
Have you tried usong the almighty Google[^]? 536,000 results to do what you are asking, in 5 seconds
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
I tried using Google but i didn't get the required solution for my problem.
If u know the solution u answer it instead of criticizing
|
|
|
|
|
Jeminwins wrote: I tried using Google but i didn't get the required solution for my problem.
Ok. You will rarely find the "required solution" for your "problem." That is part of being a developer. You need to be able to do the necessary research for your project, and then apply what you learned to your project and tailor it to meet your needs.
Jeminwins wrote: If u know the solution u answer it instead of criticizing
Don't tell me what to do. I'm not going to answer a damn thing for you. I wasn't criticizing you. I simply told you to look on google, because there were thousands of articles that you could have read, learned from, and applied to your project. Instead of doing that, you came to code project and listed your requirement and expected someone to do your work for you. There wasn't even a question in your original post to answer. This isn't rent-a-coder. Do the damn research yourself, and when you get stuck at a specific spot, you can ask a specific question.
What have you tried to do to solve that solution, huh? Maybe barely search google for your exact solution, with full source code? Go to every forum you could think of and list your requirement, with no questions, and expect someone to waste their time doing your work? We help for free, when we feel like it. Why would someone help you, when you probably haven't tried to solve the problem yourself. Lazy ass Indian. That is why Indians get such a bad rep. People like you. You act like everyone owes you something. You believe we should do your work, research, and write code for you. You lazy ass. I can't believe people like yourself call yourself a developer.
I'm going to become rich when I create a device that allows me to punch people in the face over the internet.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
|
|
|
|
|
Justin
I do love a good dummy spit . Onya lad
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
In vb.net 2005 we can not use oracle database 8.0.5 at desing time.For this we need to use the connection string at run time to execute queries.
I have a customers form and using treeview to display the customers and by selecting the customer from the treeview I need to show the detail of the selected customer in the controls like (TextBox,ComboBox).I can get the detail by running the following query but don't know how to bind the controls after getting the result.
Using the following query to get the result of the selected customer.
"Select * from customers where custcode = '" & mcustcode & "'
Any idea or any sample code which can help.
Thanks In advance
Ejaz
|
|
|
|
|
Explaining the basics of data access in .NET is beyond the scope of a forum post. I suggest you buy a beginner's book on VB.NET and ADO.NET.
A quick Google search[^] also threw up some articles you may like to read.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Try something like this :-
myTextBox.DataBinding.Add("Text", myDataSet.Table(0), "FieldToBind")
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
Hi all,
I have a bit of an issue with some code I am designing.
I am trying to implement a "file open" dialog for images. There are reasons for not wanting to use the standard dialogs. Also, I want the control to remain responsive whilst displaying a the list, so a user can select "up", or another folder whilst the list of preview images is loading.
To do this, I have a panel object, and my own "simpleimage" which is a simple control which has an image and a caption. I draw the a small preview thumbnail image to the simple control then add this to the panel.
To keep the app responsive, the creating of these simple images is done in a background worker, and a delegate adds them to the panel.
Delegate Sub AddIconDelegate(ByVal s As SimpleImage)<br />
<br />
Private Sub AddIcon(ByVal s As SimpleImage)<br />
SyncLock Me.ImagePanel<br />
Me.ImagePanel.Controls.Add(s)<br />
End SyncLock<br />
End Sub
and, in the background worker:
Loop through relevant images<br />
Dim Blob As New SimpleImage(MyCL, ImageTypeEnum.Image, FileName, Cap)<br />
AddHandler Blob.ImageSelected, AddressOf ImageSelectedHandler<br />
Blob.Location = New Point(xp, yp)<br />
Me.ImagePanel.Invoke(ASI, Blob)<br />
End Loop.
And the scrollbar:
Private Sub _ValueChanging(ByVal Sender As vScroller) Handles VS1.ValueChanging<br />
SyncLock Me.ImagePanel<br />
Me.ImagePanel.Top = -VS1.Value<br />
End SyncLock<br />
End Sub
This code generally works fine. I have successfully added over 4000 images.
I can mess around with the scrollbar which controls the panels position (move it up and down) and generally things are fine, BUT if I go crazy and move the scroll bar really crazily, the invoked procedure (AddIcon), more specifically the "Me.ImagePanel.Controls.Add(s)" line, will cause a StackOverflowException. This can happen with only 300 icons.
So, Question time.
Does anyone know why this is happening?
Any way of catching the stackoverflow exception?
I have tried slowing the backgroundworker down with a thread.sleep, and this reduces the chance if it happening, but does not eliminate it. The synclock also reduces the chance of this happening.
Thanks in advance.
Jason
|
|
|
|
|
Hi
Is there more code? maybe some eventhandlers on the imagepanel?
and ther's one more thing:
your syncLock is useless
basically you're of coure right that you must lock resources when you modify them from different threads. but since you call your AddIconDelegate correctly via Invoke of ImagePanel it's executed through the main-thread of your application. so no syncLock required here.
but anyway that's not the problem here...
you should take a look at the CallStack in your debugger when the exceptions comes up.. maybe that gives you an idea what's called from where over and over...
greets
m@u
|
|
|
|
|
Hi,
Thanks for the reply.
The Synclock was an attempt at curing the problem, and it does seem to reduce the problem... but then again, maybe it doesnt . I will remove these lines!
There isn't really much more code. The imagepanel has no eventhandlers defined by me, and its only function is that of a container to hold all the other controls. I only access its "Top" value, setting it depending upon a scrollbar position.
The background worker does "report progress" which increments a progress bar on the main thread, but that is about all I'm afraid for the code in the form.
The exact exception reported is rather useless (well, to me and Uncle Google):
System.StackOverflowException was unhandled<br />
An Unhandles Exception of type 'System.StackOverflowException' occurred in mscorelib.dll<br />
Make sure you do not have an infinite loop or infinite recursion.
I certainly dont have an infinite loop, and I cant find out where in mscorelib.dll this is occuring.
Thanks again.
|
|
|
|
|
yes that's right the message of the Exception is not really interesting.. but the StackTrace might speak books
|
|
|
|
|
Hi yet again.
I think I have found the problem, and the fix.
I was being polite to the system, and doing an application.doevents whilst in the backgroundworker's reportprogress event, after updating the progressbar. I have removed this "polite" code, and now it is still responsive, but will not crash.
This must have been a left-over from the single threaded version of the control.
Thanks for your time.
Jason
|
|
|
|
|
Hi
Using VS2005 VB
I am having Problems when importing data from an Excel sheet using oledb
The sheets being opened as always use the following naming convention
P_W03-29M40MH-S16A-1235296-XFA-
The problem seems to be the dash at the end.
If I rename the sheet and replace the dash with an underscore, it works fine
I dont want to have to open the book first an rename the sheets every time.
The code below throws an error when cmd.Execute reader executes.
The error states:
System.Data.OleDb.OleDbException = {"The Microsoft Jet database engine could not find the object 'P_W03-29M40MH-S16A-1235296-XFA-$.A:A'.
Make sure the object exists and that you spell its name and the path name correctly."}
This is the code I am using:
<br />
<br />
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _<br />
"Data Source=C:\myFile.xls;" & _<br />
"Extended Properties=""Excel 8.0;HDR=NO"""<br />
<br />
Dim conn As New System.Data.OleDb.OleDbConnection(strConn)<br />
conn.Open()<br />
<br />
Dim strSheet As String = "P_W03-29M40MH-S16A-1235296-XFA-"<br />
Dim cmd As New System.Data.OleDb.OleDbCommand("Select * from [" & strSheet & "$A:A]", conn)<br />
Dim rdr As OleDbDataReader = cmd.ExecuteReader
|
|
|
|
|
Just off the top of my head: have you tried concatenating a ! in between the sheet name and the range?
"Select * from [" & strSheet & "!$A:A]"
or you could try one of the following alternative syntaxes:
"Select * from ['" & strSheet & "$A:A]"'"
"Select * from ['" & strSheet & "'$A:A]"
"Select * from ['" & strSheet & "'!$A:A]"'"
My advice is free, and you may get what you paid for.
|
|
|
|
|
Thanks, tried them but no luck.
The '$' sign is eqivalent to the '!' usually used to indicate a sheet in an Excel Formula.
I tried the same query in MS Query from Excel, and it gave the similar syntax and it works with the '-' at the end.
The only difference was it the Filed name was as follows
SELECT * FROM mysheetName$.F1
Do you know how to use an escape character for '-'. Mabee I can get the sheet name, strip off the dash, and insert a dash with an escape character sequence?
|
|
|
|
|
The problem with Excel programming (in my experience) is that any code is rather sensitive to (MS Excel) version differences.
I don't know if there is any kind of special escape character you could use, but one thing you can try is the "add quotes till it works" method. Something like this:
"SELECT * FROM ['" & mysheetName- & "'$.F1]"
next "SELECT * FROM [" & "'" & " & mysheetName- & " & "'" & "$.F1]"
or "SELECT * FROM [''" & mysheetName- "''$.F1]"
next "SELECT * FROM ['''" & mysheetName- "'''$.F1]"
etc. (and you can try variations of the location of the quotes)
One other option that came to mind was to try and use the sheets index instead of its name. I found this article that may be helpful: http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm[^]
and a third option that came to mind is to first programmatically change the sheet name before you run the query against it (a bit clumsy, but once it runs, who cares right?).
And in conjunction to this idea: the sheet (name) seems to also get created by some sort of automatic process. Do you have access to this process?
My advice is free, and you may get what you paid for.
|
|
|
|
|
Hi
I have tried various options with the quotes with no sucess.
Once I have selected the workbook from which I want to import the sheet, I load the sheets in the workbook into a combo. The user can then select which sheet they want to import. I do this as follows:
<br />
For Each sheet As Excel.Worksheet In xlPacklistBook.Sheets<br />
Me.cboPackListSheetSelect.Items.Add(sheet.Name)<br />
Next<br />
Regarding the second option, I did try using the sheet index, but that did not work. I suspect it is because in the following code, the command data type is a string:
<br />
Dim cmd As New System.Data.OleDb.OleDbCommand("Select * from ['" & strSheet & "$.A:A]'", conn)<br />
In Excel VBA if you use Sheet(1) as a ref to a sheet, the one is an int value, not a string as in Sheet("mySheet")
I'm trying th e third option at the moment, but having hassles - I'll let you know if I get it right..
|
|
|
|
|
hi...
i developed a win application in vb.net..in that i had some report files, images , & other files.. all these are kept in seperate folders like reports in reportfolder, images in Imagefolder.... i created set up for the application... the installed application is working properly in "All users", and in network tooo...
but when i install the application in domain its not printing the report.... the printer is shared from one of the domain Pc.
And also if i remove the reports folder from the installed directory.. still the report is previewing....
do any idea..
|
|
|
|
|
Greettings again;
I am working on POS software in visual basic 2005/08 and have run into a problem that I just can't seem to wrap my mind around. This POS is designed for Taverns and as thus I need to setup various happy hour specials. Right now I have a working POS setup and functioning in a very basic environment but I am not at all happy with how the happy hour routine works. Specifically how I deal with the days of the week that specials apply.
Right now for each happy hour special I have an individual variable that indicates if the special runs on that specific day. For example HHMon(x), HHTue(x), HHWed(x) etc as boolean variables. True means the special is on that day, false it is off. Some specials run on Monday and Thursday, others run one day a week, others run weekdays, so on and so on. I just feel it is such a waste and inefficient to use seven variables for each special.
So my question is, does anyone have an suggestions on how to better approach dealing with days of the week in this fashion? Could a single variable represent every possible combination of week days? Is there a built in function that would do this? I am very new to VB.NET and programming in general and I would appreciate any assistance.
Thank You,
Ryan
modified on Thursday, January 31, 2008 3:08:55 AM
|
|
|
|
|
Ryan - I hope that is an Irish Ryan and working in a pub - some people do have the luck.
This problem is not a VB or coding problem, it is a data structure issue. Put out of your mind the idea of having 1 variable to cater for all types, it aint gonna happen.
I would start with some?
Do you have multiple HHs in a day?
Do you have different types of HH?
Do the HHs change time and length from 1 day to the next?
Do prices vary for different HH types?
What about ad hoc HHs (public hols)?
Can management cancel an HH at short notice?
How many pints can I drink in 1 HH - oops
The answer to these (and there will probably be more I have not thought of) will determine the shape of your data structure. And if you think some of them are silly in Singapore they have all of the above and some products have different discount rates for AM/PM HHs.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hello every one,
I am using DataGridView in 2-3 forms in my application
In one of my forms I have 3 girds and if I alter any thing in the design mode then the default cell header and default cell style changes. But the alternate row style remains what I had saved as.
Dose any one has a idea of how to get rid of this problem
Regards
Nshkarsh
|
|
|
|
|
What do you mean by "problem"? From what you've described, this is normal behavior, depending on what you changed and how your code is written. You haven't said anything about what you expect it to do, or what you changed in the Properties of the DataGridView.
|
|
|
|
|
Hi Dave
I think I had not described the issue properly…
I will try to define it again it again
In one of my forms I am suffering with the following issue
- Once I change the font and sizes of the rows in a datagridview save it then it works fine
- Once I change even the location of any other object, say a label, on that form all the properties changes (fonts and size) done in datagridview are set back to the default
Id there a way out?
|
|
|
|