Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. help help help

help help help

Scheduled Pinned Locked Moved Visual Basic
helpcsharpdatabasedata-structures
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gaigoi113
    wrote on last edited by
    #1

    Hello everyone, I'm working on an application using VB.Net and Access. The program will read a text file similar to this --> IM,CRP-FURT-0044148,D,0,@PROD02;IMAGES\00\00;CRP-FURT-0044148.TIF;2 IM,CRP-FURT-0044149, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044149.TIF;2 IM,CRP-FURT-0044150, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044150.TIF;2 IM,CRP-FURT-0044151, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044151.TIF;2 .. and save it to access database, but I keep getting [ array out of bound error ] & [ object reference not set to an instance of an object ] code for when click import: conv1.ShowDialog() If (Not conv1.convFilePath Is Nothing) Then Me.theDbConnection = db1.createNewDb flag1 = db1.importData(Me.theDbConnection, conv1.convFilePath) End If If flag1 Then Try Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection) Me.dataGridImgs.DataSource = table1 Me.currentRec.Text = ("1\" & table1.Rows.Count) << objct reference not set error Catch obj As ObjectDisposedException MessageBox.Show(obj.Message) End Try End If ---------- Function for the text delimiter file Private Function cnvtIpro(ByVal cnvtFile As String, ByVal outFile As String) As Boolean Dim flag1 As Boolean = True Try Dim reader1 As New StreamReader(cnvtFile) Dim writer1 As New StreamWriter(outFile) Dim textArray3 As String() = reader1.ReadToEnd.Split(New Char() {ChrW(10)}) Dim num1 As Integer = textArray3.Length reader1.Close() Dim num2 As Integer = 0 Do While (num2 < num1) Try Dim textArray1 As String() = textArray3(num2).Trim.Split(New Char() {","c}) If (textArray1.Length > 1) And (textArray1(0).ToUpper Is "IM") Then Dim textArray2 As String() = textArray1(4).Split(New Char() {";"c}) Dim text1 As String = Me.setOutLine(textArray1(1), Path.GetDirectoryName(cnvtFile), (textArray2(1) & "\" & textArray2(2)), textArray1(2), textArray2(0).TrimStart(New Char() {"@"c}), "0") writer1.WriteLine(text1) End If Catch exception1 As Exception Dim result1 As DialogResult = MessageBox.Show((textArray3(num2) & " :INVALID"), exception1.Message, MessageBoxButtons.OKCancel, MessageBoxIc

    D 1 Reply Last reply
    0
    • G gaigoi113

      Hello everyone, I'm working on an application using VB.Net and Access. The program will read a text file similar to this --> IM,CRP-FURT-0044148,D,0,@PROD02;IMAGES\00\00;CRP-FURT-0044148.TIF;2 IM,CRP-FURT-0044149, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044149.TIF;2 IM,CRP-FURT-0044150, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044150.TIF;2 IM,CRP-FURT-0044151, ,0,@PROD02;IMAGES\00\00;CRP-FURT-0044151.TIF;2 .. and save it to access database, but I keep getting [ array out of bound error ] & [ object reference not set to an instance of an object ] code for when click import: conv1.ShowDialog() If (Not conv1.convFilePath Is Nothing) Then Me.theDbConnection = db1.createNewDb flag1 = db1.importData(Me.theDbConnection, conv1.convFilePath) End If If flag1 Then Try Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection) Me.dataGridImgs.DataSource = table1 Me.currentRec.Text = ("1\" & table1.Rows.Count) << objct reference not set error Catch obj As ObjectDisposedException MessageBox.Show(obj.Message) End Try End If ---------- Function for the text delimiter file Private Function cnvtIpro(ByVal cnvtFile As String, ByVal outFile As String) As Boolean Dim flag1 As Boolean = True Try Dim reader1 As New StreamReader(cnvtFile) Dim writer1 As New StreamWriter(outFile) Dim textArray3 As String() = reader1.ReadToEnd.Split(New Char() {ChrW(10)}) Dim num1 As Integer = textArray3.Length reader1.Close() Dim num2 As Integer = 0 Do While (num2 < num1) Try Dim textArray1 As String() = textArray3(num2).Trim.Split(New Char() {","c}) If (textArray1.Length > 1) And (textArray1(0).ToUpper Is "IM") Then Dim textArray2 As String() = textArray1(4).Split(New Char() {";"c}) Dim text1 As String = Me.setOutLine(textArray1(1), Path.GetDirectoryName(cnvtFile), (textArray2(1) & "\" & textArray2(2)), textArray1(2), textArray2(0).TrimStart(New Char() {"@"c}), "0") writer1.WriteLine(text1) End If Catch exception1 As Exception Dim result1 As DialogResult = MessageBox.Show((textArray3(num2) & " :INVALID"), exception1.Message, MessageBoxButtons.OKCancel, MessageBoxIc

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      First, I'm not reading through all this junk trying to find out where the error is. Point out on which line the errors occur and keep the code snippets to a relative minimum. You've posted WAY too much. The error "object reference not set to an instance of an object" is cuased because your trying to use an object that doesn't exist. For example, in your first code snippet, your code is making a couple of very bad assumptions.

      Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
      Me.dataGridImgs.DataSource = table1
      Me.currentRec.Text = ("1\" & table1.Rows.Count)

      When you call imgs1.fillDataTable(Me.theDbConnection), did it actually return anything?? If not, then table1 doesn't refer to table, hence you can't call any methods on it, which your doing 2 lines later. Second, in the Me.currentRec.Text... line, even if table1 points to an actual table object, does it contain any Rows? Probably not. Check the status of your objects before you try and use them. Maybe something like this:

      Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
      If Not table1 Is Nothing Then
      Me.dataGridImgs.DataSource = table1
      If table1.Rows.Count > 0 Then
      Me.currentRec.Text = ("1\" & table1.Rows.Count)
      End If
      End If

      The error "Array out of bounds" means that you're trying to get at more objects in an array than are actually contained in the array. For example, if there are 10 objects in an array, they're indexed as 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. You're trying to get at index number 10 when it doesn't exist.

      Dave Kreskowiak Microsoft MVP - Visual Basic

      P G 2 Replies Last reply
      0
      • D Dave Kreskowiak

        First, I'm not reading through all this junk trying to find out where the error is. Point out on which line the errors occur and keep the code snippets to a relative minimum. You've posted WAY too much. The error "object reference not set to an instance of an object" is cuased because your trying to use an object that doesn't exist. For example, in your first code snippet, your code is making a couple of very bad assumptions.

        Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
        Me.dataGridImgs.DataSource = table1
        Me.currentRec.Text = ("1\" & table1.Rows.Count)

        When you call imgs1.fillDataTable(Me.theDbConnection), did it actually return anything?? If not, then table1 doesn't refer to table, hence you can't call any methods on it, which your doing 2 lines later. Second, in the Me.currentRec.Text... line, even if table1 points to an actual table object, does it contain any Rows? Probably not. Check the status of your objects before you try and use them. Maybe something like this:

        Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
        If Not table1 Is Nothing Then
        Me.dataGridImgs.DataSource = table1
        If table1.Rows.Count > 0 Then
        Me.currentRec.Text = ("1\" & table1.Rows.Count)
        End If
        End If

        The error "Array out of bounds" means that you're trying to get at more objects in an array than are actually contained in the array. For example, if there are 10 objects in an array, they're indexed as 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. You're trying to get at index number 10 when it doesn't exist.

        Dave Kreskowiak Microsoft MVP - Visual Basic

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #3

        Dave Kreskowiak wrote:

        You've posted WAY too much.

        Yep, that is why I read it only a quarter of a way through, and then went to different forum :rolleyes:


        Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon

        1 Reply Last reply
        0
        • D Dave Kreskowiak

          First, I'm not reading through all this junk trying to find out where the error is. Point out on which line the errors occur and keep the code snippets to a relative minimum. You've posted WAY too much. The error "object reference not set to an instance of an object" is cuased because your trying to use an object that doesn't exist. For example, in your first code snippet, your code is making a couple of very bad assumptions.

          Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
          Me.dataGridImgs.DataSource = table1
          Me.currentRec.Text = ("1\" & table1.Rows.Count)

          When you call imgs1.fillDataTable(Me.theDbConnection), did it actually return anything?? If not, then table1 doesn't refer to table, hence you can't call any methods on it, which your doing 2 lines later. Second, in the Me.currentRec.Text... line, even if table1 points to an actual table object, does it contain any Rows? Probably not. Check the status of your objects before you try and use them. Maybe something like this:

          Dim table1 As DataTable = imgs1.fillDataTable(Me.theDbConnection)
          If Not table1 Is Nothing Then
          Me.dataGridImgs.DataSource = table1
          If table1.Rows.Count > 0 Then
          Me.currentRec.Text = ("1\" & table1.Rows.Count)
          End If
          End If

          The error "Array out of bounds" means that you're trying to get at more objects in an array than are actually contained in the array. For example, if there are 10 objects in an array, they're indexed as 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. You're trying to get at index number 10 when it doesn't exist.

          Dave Kreskowiak Microsoft MVP - Visual Basic

          G Offline
          G Offline
          gaigoi113
          wrote on last edited by
          #4

          Thanks Dave for pointing it out. And yes I'm really sorry about posting too much. It wont happen again.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups