|
Thx. But what should i do? How to optimize?
FYI, i 've change to use sqldataadapter, it seems to use less memory, but still it wont free up after used.
and btw, as can seen from my code, i used oracle reader too. it does not have any problem.
Wat key(s) do gamer press most?
> WASD
Wat key(s) do Programmer press most?
> Ctrl C + Ctrl V
|
|
|
|
|
Well, one way would be to write a bunch of SQL so you send it all at once and get a single dataset back instead of using readers over and over for every result you want.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Make sure that you dispose all the disposable objects that you use. I see at least one OracleCommand object that you leave open and undisposed. As you do this in a loop, that's one connection for each selected item.
Don't call GC.Collect. The garbage collector knows better when a garbage collection should be done.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
sorry for misleading. Actually it's the sqlserv.exe that use up the memory. My oracle.exe is working fine. MICROSOFT ......
Wat key(s) do gamer press most?
> WASD
Wat key(s) do Programmer press most?
> Ctrl C + Ctrl V
|
|
|
|
|
It's normal for SQL Server to use any available memory for caching, that is the default setting. If you are running the SQL Server on the same computer as the application, you have to limit the amount of memory that SQL Server uses, so that there is some left for the application.
Normally it takes days or weeks until SQL Server uses all available memory, but as you are fetching everything everytime in your query, it will go a lot faster.
Verify that you close and dispose everything, not just the one object that I found at a quick read-through. I also see an SqlCommand object that you leave open and undisposed. That means that one connection is left open for each selected item, which uses a bit of memory for buffers, and also keeps the result in memory as you leave it unread. The connections will time out after a while, but you are probably running into problems before the timeouts starts to free up enough connections.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i've tried to do some testing. this is my testing code
Dim sqlCOn As New SqlConnection("Server=localhost;Database=phxtest;Trusted_Connection=yes")
Dim sqlda As SqlDataAdapter
Dim sqldt As DataSet
Dim sqlFieldCount As Integer
sqlCOn.Open()
Dim SqlCommand As New SqlCommand("select top 0 * from msaspot", sqlCOn)
sqlda = New SqlDataAdapter(SqlCommand)
sqlDt = New DataSet
sqlDa.Fill(sqlDt) ## Here is where it use up the memory ##
sqlDa.Dispose()
sqlFieldCount = sqldt.Tables(0).Columns.Count
sqldt.Clear()
sqldt.Dispose()
SqlCommand.Dispose()
sqlCOn.Close()
sqlCOn.Dispose()
Wat key(s) do gamer press most?
> WASD
Wat key(s) do Programmer press most?
> Ctrl C + Ctrl V
|
|
|
|
|
I am having a problem dragging and dropping into a datagrid. I have the code, and it works for certain cells in the datagrid, but items that are dates or integers (as opposed to strings) the hittest does not work. Here's the code:
Private Sub DataGrid1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGrid1.DragDrop Dim lbl As String = DirectCast(e.Data.GetData(GetType(String)), String) Dim Index As Integer TextBox1.Text = lbl DataGrid1.BorderStyle = BorderStyle.Fixed3D Dim pt As Point = DataGrid1.PointToClient(New Point(e.X, e.Y)) Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt.X, pt.Y) hitRow = hti.Row hitCol = hti.Column If hti.Type = DataGrid.HitTestType.Cell Then DataGrid1(hti.Row, hti.Column) = lbl End If Label6.Text = hitRow Label7.Text = hitCol Label9.Text = Me.DataGrid1(hti.Row, 8).ToString() End Sub
Any ideas? ![Confused | :confused:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_confused.gif)
|
|
|
|
|
Sorry about the code formatting. Here it is (it wouldn't let me edit it)
Private Sub DataGrid1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGrid1.DragDrop
Dim lbl As String = DirectCast(e.Data.GetData(GetType(String)), String)
Dim Index As Integer
TextBox1.Text = lbl
DataGrid1.BorderStyle = BorderStyle.Fixed3D
Dim pt As Point = DataGrid1.PointToClient(New Point(e.X, e.Y))
Dim hti As DataGrid.HitTestInfo = DataGrid1.HitTest(pt.X, pt.Y)
hitRow = hti.Row
hitCol = hti.Column
If hti.Type = DataGrid.HitTestType.Cell Then
DataGrid1(hti.Row, hti.Column) = lbl
End If
Label6.Text = hitRow
Label7.Text = hitCol
Label9.Text = Me.DataGrid1(hti.Row, 8).ToString()
End Sub
|
|
|
|
|
Hi,
Phantom715 wrote: DirectCast(e.Data.GetData(GetType(String)), String)
so you are accepting a string
Phantom715 wrote: DataGrid1(hti.Row, hti.Column) = lbl
and storing it in a cell; what if the cell isn't expecting a string? shouldn't you parse numbers, dates, etc.?
|
|
|
|
|
Okay, I guess I wasn't specific enough. I don't necessarily need it to put anything in the datagrid (although that would be nice to know for future purposes ). I need to automatically recognize which row the item was dropped onto. When the datatype in the cell doesn't match what is being dropped, it doesn't perform the hittest. (I think )
|
|
|
|
|
OK, so use the row and/or column number to decide whether you want to drop the string,
add the result of such tests to the line If hti.Type = DataGrid.HitTestType.Cell .
That should take care of it.
BTW: sounds like you must do the same in DragEnter/DragOver handlers to get correct UI behavior.
|
|
|
|
|
Awesome, thanks! The DragEnter/Dragover was what I needed! All I did was enter the hittest into both of those subs, and it recognizes now. Thank you very much.
|
|
|
|
|
You're welcome.
|
|
|
|
|
Is it possible to create an instance of a managed object without containing a reference to the same object (using VB 2005)?
Normally, you would add references to various .dlls and then create objects based on the references.
Is it possible to create objects from .dlls that are not referenced by the project? The .dlls in question are managed objects, so I don't think CreateInstance will work since that is for COM objects.
Any pointers or general guidance on what to look for would be helpful. Thanks!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) Look at LoadAssembly
We called our routines CreateInstance but there's 3 flavors. by default it looks local/gac. but you can specify a location.
Public Shared Function CreateInstance(ByVal sFullClassName As String) As Object
Dim ao As [Assembly], aoName As New AssemblyName
Dim o As Object
Try
aoName.Name = sFullClassName.Substring(0, sFullClassName.LastIndexOf("."))
ao = [Assembly].Load(aoName)
o = ao.CreateInstance(sFullClassName, True)
Catch ex As Exception
Try
ExceptionManager.HandleClientException("Exception creating an instance of " & sFullClassName & ".", ex)
Catch : End Try
Throw ex
End Try
ao = Nothing
Return o
End Function
Public Shared Function CreateInstance(ByVal sAssembly As String, ByVal sClass As String) As Object
Dim ao As [Assembly], aoName As New AssemblyName
Dim o As Object
Try
aoName.Name = sAssembly
ao = [Assembly].Load(aoName)
o = ao.CreateInstance(sAssembly & "." & sClass, True)
Catch ex As Exception
'ExceptionManager.PublishException(ex)
Throw ex
End Try
ao = Nothing
Return o
End Function
Public Shared Function CreateInstance(ByVal sFullPathIncludingFileName As String, ByVal sAssembly As String, _
ByVal sClass As String) As Object
Dim ao As [Assembly], o As Object
Try
ao = [Assembly].LoadFrom(sFullPathIncludingFileName)
o = ao.CreateInstance(sAssembly & "." & sClass, True)
Catch ex As Exception
'ExceptionManager.PublishException(ex)
Throw ex
End Try
ao = Nothing
Return o
End Function
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
modified on Tuesday, December 9, 2008 1:57 PM
|
|
|
|
|
That's exactly what I am trying to do.
Next dumb question:
So once the obj is created, how do you call the object's methods? Are you using a directcast with another method of the ao object?
Nevermind, I think i got it figured out (create type, methodinfo, call method etc).
Thanks for the guidance!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
modified on Tuesday, December 9, 2008 2:54 PM
|
|
|
|
|
Actually - when you do a loadassembly you don't have to use reflection any longer. It is the same as saying Dim MyObj as new Test. Once you have the object that is returned just access it's properties/fields/methods as before like it was referenced.
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
'Life's real failure is when you do not realize how close you were to success when you gave up.' ~ anonymous
|
|
|
|
|
nlarson11 wrote: Actually - when you do a loadassembly you don't have to use reflection any longer. It is the same as saying Dim MyObj as new Test. Once you have the object that is returned just access it's properties/fields/methods as before like it was referenced.
Sigh........you are correct.
Turning Option Strict Off allows me to this now. I am so used to always have Option Strict/Explicit set that I forget about the consequences sometimes.
Thanks for the help!
Any suggestions, ideas, or 'constructive criticism' are always welcome.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hello All,
I am developing a MDI application in vb.net 3.5
but I am fecing a problem a when i am pressing "Ctl" + "Tab" button of the keyboard.
As I open all the child form in maximise mode so, I do not want to press "Ctl+Tab" to suffle the childform
So, How can I stop that in my application.
Arindam Banerjee
Sr. Software Developer
Rance Computer Pvt Ltd.
Kolkata (India)
|
|
|
|
|
I've never turned the thing off myself, so, this may not work.
But, I'd start by turning Keypreview on the MdiParent form on, then handle it's KeyDown event and eat the Tab key if Ctrl is being held down.
|
|
|
|
|
Please let me know the property with which I can accomplish the above mentioned task.
For more clearity here is an example:
Suppose I have a combobox with name- cboProject
and my Two strings are - Puneet, India
DesiredTask: I want to add both these strings to 0th Index of cboProject and at the same point of time hide the text followed by "," i.e hide India.
Thanks & Regards
Puneet
|
|
|
|
|
oh dear god... try attempting it before you ask!
string3 = string1 + string2
|
|
|
|
|
GriffinPeter wrote: oh dear god... try attempting it before you ask!
string3 = string1 + string2
That's not really what the OP is asking, I think
|
|
|
|
|
Puneet Bhatnagar wrote: DesiredTask: I want to add both these strings to 0th Index of cboProject and at the same point of time hide the text followed by "," i.e hide India.
You would have to create a multi-column combo box for this. A simple search brings me to this[^] article on CP.
|
|
|
|
|
If you only need two columns and one will always be hidden you could try the following:
create a datatable with 2 columns
fill the datatable with the data you want
assing the datatable to the cboproject.datasource property
assing the cboproject.valuemember property to the columnname from the column to be hidden
assing the cboproject.displaymember to the columnname from the column to be shown
The multi column combobox mentioned by ChandraRam could give you more options tho.
|
|
|
|