Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to close an object

Author  Topic 

Kristin
Starting Member

16 Posts

Posted - 2004-07-12 : 13:10:13
Anyone know how to close a datagrid object? I have created a search form which displays results in a datagrid. I need a command to clear the datagrid so I can performa new search without completely exiting the application.

any ideas anyone?

thanks mucho!
kristin

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-07-12 : 13:57:02
This is .NET right?

If you want to clear out a datagrid you can always bind a null value to it and rebind it.

datagrid.DataSource = null;
datagrid.DataBind()

Dustin Michaels
Go to Top of Page

Kristin
Starting Member

16 Posts

Posted - 2004-07-12 : 14:53:24
nope, vb 6.0
Go to Top of Page

chacha
Starting Member

39 Posts

Posted - 2004-07-13 : 00:55:13
wait, if I remember back that far, you don't close the datagrid object- this is ADO right? You close the recordset or connection, then deallocate it's memory by setting it = null.
Go to Top of Page

Kristin
Starting Member

16 Posts

Posted - 2004-07-13 : 10:18:54
Sounds good:) but how do I code it:) so NOT the coding guru yet, hahahah. I've tried everything, can't get it to work!
Go to Top of Page

chacha
Starting Member

39 Posts

Posted - 2004-07-13 : 16:27:28
you had to create an ado connection object or an ado recordset or both to open a connection to the database, right? then you probably databound the datagrid to the connection using the Datasource property of the datagrid, right? So, after you are finished using connection, you call it's Close method and then deallocate the memory it is using by setting it equal to null

myAdoConnection.Close
Set myAdoConnection = Null

It has been a long time since I used VB 6, I don't remember if you have to explicitly use the Set syntax to set an object reference to null. Try this anyhow. Search the web for your answer. It is out there for sure. This is as basic as it gets.
Go to Top of Page

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2004-07-20 : 17:19:34
Try the keyword Nothing instead of Null.

Set myConn = Nothing

-----------------------------------------------------
Words of Wisdom from AjarnMark, owner of Infoneering
Go to Top of Page
   

- Advertisement -