Click here to Skip to main content
16,005,169 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: vb.net / Crystal Report Pin
Dave Kreskowiak12-Oct-04 9:02
mveDave Kreskowiak12-Oct-04 9:02 
GeneralAppend to a string Pin
Brad Fackrell12-Oct-04 6:06
Brad Fackrell12-Oct-04 6:06 
GeneralRe: Append to a string Pin
Colin Angus Mackay12-Oct-04 6:27
Colin Angus Mackay12-Oct-04 6:27 
GeneralRe: Append to a string Pin
Brad Fackrell12-Oct-04 7:17
Brad Fackrell12-Oct-04 7:17 
GeneralError: Object reference not set to an instance of an object Pin
Mekong River12-Oct-04 4:16
Mekong River12-Oct-04 4:16 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Dave Kreskowiak12-Oct-04 5:22
mveDave Kreskowiak12-Oct-04 5:22 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Mekong River12-Oct-04 23:52
Mekong River12-Oct-04 23:52 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Mekong River13-Oct-04 1:16
Mekong River13-Oct-04 1:16 
Dave Kreskowiak wrote:
It's bad practice to use "global" objects like this. What your doing in your code is, apparently, when the form is opened creating and HOLDING ON TO database connections and resources and not releaseing them until the form closes. You should NOT do this. Database resources are expensive and should be opened, used, and then released as soon as possible, preferrably inside the same method.

Dave, I wonder about the code that I get it the first time before I customize it:

dim cnn as New ADODB.Connection
dim rst as New ADODB.Recordset

Privat Sub Form1_Load()

        cnn.Open("Provider...;Data Source=...")
        ' Get the record from the table.
        rst.Open("SELECT * FROM [TableName]", cnnCat)
        ' ...
        ' The code to check the record and put it on the form.

        rst.Close
        cnn.Close

        rst=Nothing
        cnn=Nothing

End Sub


The code that I wonder is the bold line:

        rst.Close
        cnn.Close

        rst=Nothing
        cnn=Nothing


I wonder: if i release the recordset and the connection, how about the code that I write for an Add new record button, Update, Delete, Move (previous, next, last, first)? Do I need to open it again? If Yes, then I have to open it again how about the record position? Does it remember the last position in the recordset? I really wonder about that, so that is the reason that I write a GLOBAL object. Could you give me some comment and correct it with a small sample code? Cry | :((



A thousand mile of journey, begin with the first step.

APO-CEDC
Save Children Norway-Cambodia Office

GeneralRe: Error: Object reference not set to an instance of an object Pin
Dave Kreskowiak13-Oct-04 1:47
mveDave Kreskowiak13-Oct-04 1:47 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Mekong River13-Oct-04 4:09
Mekong River13-Oct-04 4:09 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Dave Kreskowiak13-Oct-04 9:16
mveDave Kreskowiak13-Oct-04 9:16 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Mekong River14-Oct-04 16:45
Mekong River14-Oct-04 16:45 
GeneralRe: Error: Object reference not set to an instance of an object Pin
MohammadAmiry14-Oct-04 1:00
MohammadAmiry14-Oct-04 1:00 
GeneralRe: Error: Object reference not set to an instance of an object Pin
Mekong River14-Oct-04 16:38
Mekong River14-Oct-04 16:38 
GeneralReports/Search/Picturebox and access Pin
stevemwangi12-Oct-04 3:02
stevemwangi12-Oct-04 3:02 
GeneralRe: Reports/Search/Picturebox and access Pin
Mekong River12-Oct-04 3:37
Mekong River12-Oct-04 3:37 
GeneralError : Class Does not support Automation Pin
cberam12-Oct-04 1:02
cberam12-Oct-04 1:02 
GeneralRe: Error : Class Does not support Automation Pin
gthompson200512-Oct-04 1:37
gthompson200512-Oct-04 1:37 
GeneralRe: Error : Class Does not support Automation Pin
Anonymous12-Oct-04 17:21
Anonymous12-Oct-04 17:21 
GeneralVb.net combo box control Pin
me_vb_man11-Oct-04 23:48
me_vb_man11-Oct-04 23:48 
GeneralRe: Vb.net combo box control Pin
J4amieC12-Oct-04 1:40
J4amieC12-Oct-04 1:40 
GeneralRe: Vb.net combo box control Pin
me_vb_man12-Oct-04 5:29
me_vb_man12-Oct-04 5:29 
GeneralRe: Vb.net combo box control Pin
J4amieC12-Oct-04 8:22
J4amieC12-Oct-04 8:22 
GeneralVB.NET editor very slow Pin
Microlan11-Oct-04 21:50
Microlan11-Oct-04 21:50 
GeneralRe: VB.NET editor very slow Pin
Mekong River12-Oct-04 0:09
Mekong River12-Oct-04 0:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.