7 Replies - 330 Views - Last Post: 14 November 2011 - 01:03 AM Rate Topic: ***** 1 Votes

#1 sigridish  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 09-November 11

Object reference not set to an instance of an object

Posted 13 November 2011 - 07:15 PM

this shows up whenever i hit the save button.

Dim iCount As Integer
        Dim iLoop As Integer
        Dim query3 As New MySqlCommand
        Dim lvitem

        ConnectDatabase()
        conn.Open()
        iCount = lvLogs.Items.Count
        If Not lvLogs.Items.Count = 0 Then
            Do Until iLoop = lvLogs.Items.Count
                lvitem = lvLogs.Items.Item(iLoop)
                With lvitem
                    query3.CommandText = "insert into wer(CustomerName, SalesGroup, CustomerType, TypeOfIndustry, RM, SenioRM) values " _
                    & "('" & .SubItems(0).Text & "','" & .SubItems(1).Text & "','" & .SubItems(2).Text & "','" & .SubItems(3).Text & "','" & .SubItems(4).Text & "','" & .SubItems(5) & "')"
                    query3.ExecuteNonQuery()
                End With
                iLoop = iLoop + 1
                lvitem = Nothing
                MessageBox.Show("Record added!")
            Loop

        End If



thats my code

i've attached my project

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Object reference not set to an instance of an object

#2 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Object reference not set to an instance of an object

Posted 13 November 2011 - 07:16 PM

Okay... Dim lvitem As What exactly? You haven't given it a type.
Was This Post Helpful? 1
  • +
  • -

#3 sigridish  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 09-November 11

Re: Object reference not set to an instance of an object

Posted 13 November 2011 - 07:19 PM

what type should i assign to it?
Was This Post Helpful? 0
  • +
  • -

#4 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Object reference not set to an instance of an object

Posted 13 November 2011 - 07:22 PM

What about Dim lvitem As Object?
Was This Post Helpful? 1
  • +
  • -

#5 sigridish  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 09-November 11

Re: Object reference not set to an instance of an object

Posted 13 November 2011 - 07:29 PM

it still has the same error kindly help me. i have been doing this for a week :(
Was This Post Helpful? 0
  • +
  • -

#6 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: Object reference not set to an instance of an object

Posted 13 November 2011 - 09:41 PM

I don't see a declaration for LvLogs anywhere?
Was This Post Helpful? 0
  • +
  • -

#7 sigridish  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 65
  • Joined: 09-November 11

Re: Object reference not set to an instance of an object

Posted 14 November 2011 - 12:35 AM

lgLogs is the name of my istview
Was This Post Helpful? 0
  • +
  • -

#8 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1817
  • View blog
  • Posts: 4,625
  • Joined: 14-March 10

Re: Object reference not set to an instance of an object

Posted 14 November 2011 - 01:03 AM

Please avoid duplicate threads. You already have a topic about this here
*Topic closed*
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1