VS 2005 Connection Object + Garbage Collector?
Oct 25, 2010
with VB.NET + MySQL i am having a connection object which is public public MYcnn as MySql.Data.MySqlClient.MySqlConnection when my main form opens MYcnn will open & will be available for all the procedures & functions. i never close this connection until the last form of the application closes (yes of course i compromise of some security + performance issues)
my problems is(1)when & how the garbage collector works to collect my connection object if my connection object remains open for > then certain time(2) how to offer or fix the time of my connection object availableness to garbage collector (3) i would like to write an event for the connection object closed event(i am explicitly declaring the connection object)
View 5 Replies
ADVERTISEMENT
Mar 9, 2012
I've heard that the c# garbage collector can be 'more aggressive' than it's vb.net counterpart. Is this true? Are there any other differences in how garbage collection is run in vb.net vs. c#?
View 5 Replies
Dec 4, 2010
I have a function like the following: Public Function testFunction(ByVal input_string As String) As String
[Code]...
or just let the garbage collector do the job for us? Both the above functions work, but I want only know the best practice for performance...
View 6 Replies
May 1, 2012
I have a problem with an application, in this case I have a windows services. its function is generate reports depending of demand of our users.In some cases the memory usage of my windows services is to 2 gb of RAM. I disposed all objects that my application use . but the memory usage doesn't low.I tried to reduce the memory usage forcing to garbage collector to Collect with the method "GC.Collect"but it's not recommend because uses many time of CPU.Surfing on the internet I found a method named "SetProcessWorkingSetSize" that free memory usage correctly. http:[url]....but some cases my windows services named sapdkadm_procesoestandarejecucion.exe has some error message in event viewer is the next:
Faulting application sapdkadm_procesoestandarejecucion.exe, version 1.0.0.0, stamp 4f908fef, faulting module kernel32.dll, version 5.2.3790.4480, stamp 49c51cdd, debug? 0, fault address 0x0000000000027ded.
The real problem is that when this happens my windows services restart
View 3 Replies
Jul 7, 2011
I have prided myself in having a pretty clean code however in the game I am making I have a player view (showscreen) and a host view, which is a copy of the player view (on a smaller screen). This way the host can see what's going on.The problem is that the graphic doesn't dispose properly and Garbage Collector gets it, though I have noticed it will crash if GC doesn't get it in time. The larger the showscreen window the more junk gets put into memory, which sucks.I thought I had everything correctly disposed below but still doesn't get the job done.
[code]...
View 9 Replies
Mar 2, 2012
I may be the only person still automating excel this way and I am looking at doing it in ways that better handle COM objects and such, but for now I just importMicrosoft.Office.Interop.Excel and go for it. Something that gave me a lot of grief at first was hanging excel.exe processes, but there are tons of resources online for fixing that. At this point I am pretty confident in my abilities to handle it.One thing I did notice and was wondering about is how does closing a windows forms application interact with excel.exe running in the background and likely more specifically the garbage collector. I have written quite a few excel automation projects and noticed that after I run my program .exe and it has completed there is an excel.exe process that hangs on until I close the pop up window from the windows forms application. Why is that happening?
View 1 Replies
Oct 6, 2009
Datatable object within class function + garbage collection?
View 3 Replies
Jan 23, 2009
If I use a single variable of type Excel.Worksheet to reference Worksheet1, and then change it to Worksheet2, Worksheet3 and so on, is it adequate to simply do "Marshal.FinalReleaseComObject(worksheetVariable)" once at the end? Or would I be left with some references still in memory? In other words, do I need to do a "Marshal.FinalReleaseComObject" before each re-assignment?
View 3 Replies
Jan 29, 2009
Is the memory from primitive data types (int, char,etc) immediately released once they leave scope, or added to garbage collection for later release?
consider:
For x as integer=0 to 1000
dim y as integer
Next
If this doesn't add 1000 integers to the garbage collector for clean up later,how does it treat string objects? would this create 1000 strings to clean up later?
For x as integer=0 to 1000
dim y as string=""
Next
How about structures that contain only int,string,etc... data types?
View 13 Replies
Feb 3, 2010
I have a theory that the CLR garbage collection mechanism means that I can get away with circular references in my object hierarchy without creating deadlocks for teardown and garbage collection. Is this a safe assumption to make? (Target language VB.NET)
View 2 Replies
Jan 27, 2012
SQL connection - I planned to create one sql connection object inside my own singleton class (say connectionmanager with Reference counting for 'SQL connection object' which is a member of the class) and open/close the connection whenever needed. As I like to give high importance for performance. And my application is a desktop based application accessing a remote database server (SQL server 2008), and will use only one connection string, 50 concurrent desktop users may access db server. Please advice.
As like many articles say if the answer is "Connection pooling is taken care by ado.net" - Does that mean that scope of connection pool is entire life of Application instance? Or is it in the scope of SQLConnection object?
View 2 Replies
Apr 20, 2010
How to get email address collector in vb.net
View 2 Replies
Sep 4, 2010
i have this code in asp.net 2005 page under vb codes on myreader.Read gives me "variable myreader is used before it has been assigned a value a null reference exception" and in the ex msg " object reference not set to an instance of an object".
View 5 Replies
Nov 3, 2009
i trying to do login form, if user & password correct, then will show Main Form. First time login is no problem at all, after closed the Main Form, it will back to login form. Problem come when i try to relogin again & show "Object Reference not set to an instance of an object" when try to access the database. Attach my code here:
frmLogin -
AppPath = Environment.CurrentDirectory
DBFilename = AppPath & "DatabaseBT2 Test Results.btd"
frmMain.txtDBFilename.Text = DBFilename
[Code]....
View 3 Replies
May 12, 2009
For some reason, on the line where I try to set the value of the key, I get the following error:
Object reference not set to an instance of an object
vb Private Sub writeToKey(ByVal regValue As String)
Dim regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("SoftwareMicrosoftWindows NTCurrentVersionWindowsDevice")
regkey.SetValue("Device", regValue, RegistryValueKind.String) 'error occurs here
regkey.Close()
End Sub
View 5 Replies
Sep 28, 2010
I have compiled a Vb.Net program in which I used R Programming through R(D)COM. The statconnector library works fine. The program gives output without any error.
However whenever I try to deploy the code and create a setup file, and I run the setup file, I get the following error: There is connection for this connection ID (Exception from HRESULT: OLE_E_NOCONNECTION)
View 1 Replies
Feb 5, 2010
a) If the function returns true OR false will utilising the 'Using/End Using connection' statement close the connection cleanly? b) Is the 'Return TRUE statement' suitable placed to allow an error to occur and be raised returning a value of FALSE?
Public function doSomething () as boolean
Using conn As New SqlConnection(My.Settings.SQLConn)
Try
[code].....
View 2 Replies
Sep 8, 2009
Given a connection object (or series of them), does anyone know of a way to backtrack and get the provider name? I'm trying to create a generic dataset generator that someone could load up with n DbCommand instances populate the dataset without requiring any further information.
Theoretically, as a command requires a connection object, that's all the information one should need to create this tool.Given that I'm populating tables in a dataset, I figured the simplest way would be using a DataAdapter. The only problem is that to generate a generic DataAdapter, I seem to have to go through the provider factory which requires a provider string - which I don't have.
Also, given that the provider for each command could potentially be different (i.e. commands across numerous databases), does anyone have any suggestions that would keep this simple?I'd like not to have to require the user to provide the provider string for each command object if I can avoid it. This way the user can just pass a param array of DbCommands and I can take it from there.
View 1 Replies
Mar 28, 2012
im making a class.vb which has a sql connection. The class.vb will be used by all forms/windows on the application. So whenever a form needs to access the database, it will call class.vb.
This is the code in class.vb:
Public Sub Openconn()
Dim myConnection As SqlConnection
Dim connstring As String = "Data Source=192.162;Initial Catalog=db1;User Id=sa;Password=1;"
[code]....
but it gives error: value of type sqlconnection cannot converted to array of Sqlconnection.I just want a method that's useful for opening the connection and that is also useful when asigning to a command object.
View 8 Replies
Sep 8, 2011
I'm creating a VB.NET 2010 application which is connected to an Access 2010 database. I've set up a connection using the inbuilt connection wizard. I want to pull data from the tables using ADO.NET objects such as the data adapter to create datasets. The data adapter in ADO needs the connection object. Can I pull this from app.config? Should I junk the inbuilt connection and create a new one with code alone? Help.Scott M Brush
View 1 Replies
Sep 11, 2009
I'm designing a web service in ASP.NET and VS2008, and am using typed datasets for retrieving table data. These work well and establish their own connections through their associated TableAdapter objects. Edit: I'm using VB, BTW!I am now attempting to run a custom SQL string using a DataAdapter and a Command object, however I need to reference a Connection object in order for the Command to work. What is the best way to handle this?hould I:a) Create a global connection object using Global.asax, retrieving the connection string from web.config? (I've been trying that one already, with not much success)b) Create a class-level connection object using the InitialiseComponent method, also retrieving the ConnectionString from web.config?c) Retrieve a Connection from one of the TableAdapters that I've already created in my typed DataSets?d) Something else I haven't thought of yet?
View 2 Replies
Jun 7, 2012
I'm trying to connect to an 2007 access database. It looks like my connection string is right but I get an error stating "Object reference not set to an instance of an object."
Me.conn.ConnectionString = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\CDE Database.accdb")
My database is in the correct folder. in this case I'm debugging so I have it in my debug bin. I've even checked my application start up path to confirm that I have it in the correct folder. I also double checked my extention. For Microsoft office 2007 the extention is accdb. I've also checked the file name spelling and case etc and all matches.
I have conn set as
Private conn As OleDbConnection
View 3 Replies
Nov 5, 2009
Can I use two command object with one open connection in one procedure at VB.NET?
View 2 Replies
Oct 14, 2011
I am performing a simple exercise of opening an SQL Server database connection, pulling the first record of a table from a DataReader object, and then closing the object. However, I have noticed that theres bit of a delay, about 5 seconds or so, in closing the connection. However, the delay only occurs after the command object executes the specified query. I've worked in a setup like this before and don't remember there being such a long delay while closing the connection. [Code] The connection closes almost immediately. What gives? I have narrowed it down to the where the .ExecuteReader line that causes the delay in the connection close. Whats causing the delay and how do I resolve it?
View 2 Replies
Jun 15, 2009
I'm trying to introduce delay to my code so that it would read in the noise or garbage data.
I'm receiving the data from RFID to pic thru RS232.Is there any simple delay that i can use? I seriously don't understand threading.
View 1 Replies
Jul 23, 2010
I thought that when a variable went out of scope (like a variable declared within a method - when you exit that method the variable is out of scope) then it was eligible for garbage collection and when it was garage collected the Dispose method is called on it. Now I know that it does not get disposed immediately but I assumed it would be basically as soon as the process starts to take up quite a bit of memory.However, I found that my app's memory usage seems to constantly increase when I dont manually Dispose of a specific method local variable. Of course its good practice to call Dispose and ordinarily I would but I just didn't realise that this particular class actually implemented IDisposable. The class in question was the System.DirectoryServices.SearchResultCollection class, and I was looping through the items in it like so:
[Code]...
View 9 Replies
Mar 14, 2010
I am attempting to figure out why this code is not working in VB2005.I am trying to run a check on a set of 25 buttons in a 5 by 5 square. they are label "cmd" & X & "x" & Y whereas X and Y are the x,y coordinates.cmd1x1 through cmd5x5 I am trying for this code to set varMapBefore() to either 0(for D) or 1 (for L) for each of the buttons cmd1x1 through cmd5x5 and then join them together at the end for an output.but varMap wont act like an object. What am I doing wrong?
Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
Dim varMap(0 To 24) As Object, varMapBefore(0 To 24) As String, varMapAfter(0 To 24) As String, varCheck As String
Dim varCount As Integer, varX As Integer, varY As Integer
varCount = 0
[code]....
View 4 Replies
Dec 5, 2006
I am faced with the prospect of having to completely rewrite the application.I have suddenly started to get this error message all the time - it seemed to start after I added a table to the schema, but deleting the table makes no difference. I can't see anything wrong with the connection string, but as it seems to be entirely undocumented, that doesn't mean much.
The connection string contains DataSource=.SQLEXPRESS;AttachDbFilename=|DataDirectory| est.mdf;Integrated Security=True;User Instance=Trueand certainly the string works when I use "test connection" from the application setting edit box. I am assuming that for some reason it is not evaluating the Data Directory , but can't see any reason why it shouldn't. Any ideas gratefully received! What might be a clue though is that I can't get rid of the table I added. I have deleted it from the database, deleted it from designer and saved the file, but it just keeps reapearing! Even when it is not showing, there is still a
table adapter in the .xsd file. I am reluctant to start editing this manually because of the danger of screwing something else up - I did try but it caused an error somewhere else (VS helpfully didn't say where)
View 1 Replies
Nov 23, 2009
i am trying to run a stored procedure from my vb .net application and i am getting an error that says something like this:
"..under default settings sql server does not allow remote connections"
i have checked with my sql configurations and i have allowed remote connections but i am getting this error. besides i am connecting to my local machine so why should it give me a remote connection error.
View 12 Replies
Jan 11, 2011
I'm creating a windows forms program and have recently noticed a large amount of memory slowly being eaten by the application. I went through my program and tried to tie up as many loose ends as I could in relation to object creation but noticed that the program would still keep memory for every form loaded until it eventually crashed.
I decided to make a simple test program which sole purpose is to pop-up a new form with a few controls, wait for 200 milliseconds, then close the form and repeat the process 30 times every time I hit a button. I found it caused the same behavior, even with the only new object creation being that of the form. So, I decided to manually invoke the garbage collector in a subroutine which handles the formclosed event. During tests I would get some memory back occasionally, but not enough to make a difference in the long run. So I start setting the form variable to nothing before I called GC.collect(). The program will initially eat a few 1000K of memory before leveling off and using only 20-40K for every 30 forms created.
Now what I'm wondering is, what is the point of an automated garbage collection system if it requires constant manual evocation and explicit dereferencing of all new objects to be effective? Have I completely lost grasp on the scope of VB.Net forms and it simply never marks forms as available memory to be cleared?I would have thought object memory references created within a form would be marked as usable when the form's close or dispose routine is called and no references to objects created within the form exist anywhere outside the closed form.
View 13 Replies