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

Visual Basic

 
GeneralRe: registry monitor in vb.net Pin
addicktz13-Oct-04 9:14
addicktz13-Oct-04 9:14 
GeneralPropertygrid and listbox value and changing property description runtime Pin
David M J12-Oct-04 12:16
David M J12-Oct-04 12:16 
Generalvb.net / Crystal Report Pin
partt12-Oct-04 8:30
partt12-Oct-04 8:30 
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 
Hi, I use the following code when the form is load:

Dim cnnCat As New ADODB.Connection
Dim rstCat As New ADODB.Recordset
Dim strCatSql As String ' Hold an SQL statement.

Private Sub frmCategory_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load

    ' Combine the connection string and connect to database.
    strConnection = strProvider & strDbPath
    'MsgBox(strConnection)
    cnnCat.Open(strConnection)
    cnnCat.CursorLocation = ADODB.CursorLocationEnum.adUseClient
    ' Get the record from the table.
    strCatSql = "SELECT * FROM tblCat"
    rstCat.Open(strCatSql, cnnCat, _
    ADODB.CursorTypeEnum.adOpenKeyset, _
    ADODB.LockTypeEnum.adLockOptimistic)

    With rstCat
        If .RecordCount > 0 Then
            ' Populate the recordset.
            .MoveFirst()
            .MoveLast()
            ' Display the record on the form.
            Call ReadRecord()
        End If
    End With

End Sub


And the following code to close the form:

Private Sub btnClose_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnClose.Click

    ' Prompt the user before close the form.
    dlrUserAnswers = MessageBox.Show("Are you sure you want to close " & _
    "Category form?", "Close Category", MessageBoxButtons.YesNo, _
    MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
    If dlrUserAnswers = DialogResult.Yes Then
        ' Close database connection.
        rstCat.Close()
        cnnCat.Close()
        ' Release the objects to free memory.
        rstCat = Nothing
        cnnCat = Nothing
        ' Close the form.
        Me.Close()
    End If

End Sub


But when I start the form again, it display an error message as below:

An unhandled exception of type 'System.NullReferenceException' occurred in NGOCRC-Document Management.exe

Additional information: Object reference not set to an instance of an object.


Does anyone know why this problem occure? and how to solve this problem?



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 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 
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 

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.