473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

error in object reference not set to an instance of an object

Expand|Select|Wrap|Line Numbers
  1. Dim iCount As Integer
  2.         Dim iLoop As Integer
  3.         Dim query3 As New MySqlCommand
  4.         Dim lvitem
  5.  
  6.  
  7.         ConnectDatabase()
  8.         cona.Open()
  9.         iCount = lvLogs.Items.Count
  10.  
  11.  
  12.         If Not lvLogs.Items.Count = 0 Then
  13.             Do Until iLoop = lvLogs.Items.Count.ToString
  14.  
  15.                 lvitem = lvLogs.Items.Item(iLoop).ToString
  16.  
  17.                 With lvitem
  18.                     query3.CommandText = "insert into wer(CustomerName, SalesGroup, CustomerType, TypeOfIndustry, RM, Senior_RM) values " _
  19.                     & "('" & .SubItems(0).Text & "','" & .SubItems(1).Text & "','" & .SubItems(2).Text & "','" & .SubItems(3).Text & "','" & .SubItems(4).Text & "','" & .SubItems(5) & "')"
  20.                     query3.ExecuteNonQuery()
  21.                 End With
  22.  
  23.                 iLoop = iLoop + 1
  24.                 lvitem = Nothing
  25.                 MsgBox("New record added!")
  26.             Loop
  27.  
  28.         End If
  29.  

i think my error is declaration of variable type.

CAN SOMEBODY HELP ME?

this code is use to save imported excel file to list view then from listview, it will be saved in the DATABASE.
Nov 10 '11 #1
0 1398

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Pkpatel | last post by:
Hi, I keep getting this error every time I try to load crystalreportviewer on a webform with a dataset. Here is the error: -------------------------------------------------------- Server...
6
by: NewToDotNet | last post by:
I am getting "Object reference not set to an instance of an object. " when I attempt to open a C# windows service class in design view, although I was able to initially create the service and open...
1
by: Dave | last post by:
Hello I hope someone can give me some idea of what is causing this error. I can run though my asp app locally no problem but when i put it on the server i get this error, any help at all whould be...
6
by: blash | last post by:
Can someone help me? I really don't have a clue. My company staff told me they often got such error: "Object reference not set to an instance of an object." when they are in search result page...
18
by: Microsoft | last post by:
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object" Dim g As System.Drawing.Graphics g.DrawString("Test", New Font("Arial", 12,...
3
by: nemo | last post by:
Hi, My application works fine on the localhost but spits this error as soon as I put it on the server. I know this error occurs when an object has not been instantiated prior to a reference, but...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
7
by: Brett | last post by:
I'm not sure why I keep getting this error, "Object reference not set to an instance of an object". Private Function somefunction() as string Dim MyCurrentClass As New Class1 Try For i As...
6
by: kalaivanan | last post by:
hi, i am a beginner in c#. i have theoretical knowledge about object, reference and instance. but i want to know clearly about what is an object, reference and instance. can any one help me? or...
4
by: livmacca | last post by:
Hi, I am new to VB .Net programming and is trying to create a webpage. I encountered the following error and is totally clueless on how to make it work: ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.