Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27184

[RESOLVED]VB.NET throwing a first chance System.Data.oracleClient.OracleException

$
0
0
In Visual Studo 2010 in VBnet I have a number generator app I built that placing this numbers in a listbox. Then I wished to take the numbers generated in the listbox and insert them in an OracleDB. I set a try catch around the open connection to check if it would fail and then I set a try catch around the execture non query. The open connection works fine.. but can someone please tell me why the execute non query is failing and throwing this exception please ? It must be something simple I am overlooking here.

A first chance exception of type 'System.Data.OracleClient.OracleException' occurred in System.Data.OracleClient.dll

Code:

Imports System
Imports System.IO
Imports System.Text
Imports System.Collections.Generic

Imports System.Data.OracleClient
Imports System.Data.SqlClient



Public Class Form1

    Dim FILE_NAME As String = "C:\Documents and Settings\V-CM\Desktop\char_file.txt"
    Dim TextLine As String
    Dim Prefix As String
    Dim r_retain As String



    Dim oonConn As New OracleConnection("User Id=AAX;Password=AAX;Data Source=DEVCN")
    Dim strSQL As String
    Dim cmd As New OracleCommand(strSQL, oonConn)






    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If System.IO.File.Exists(FILE_NAME) = True Then


            Dim objReader As New System.IO.StreamReader(FILE_NAME)
            Dim sb As New System.Text.StringBuilder
            Dim mydocpath As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)

            Try

                oonConn.Open()
            Catch ex As Exception
            End Try



            Do While objReader.Peek() <> -1

                Prefix = objReader.ReadLine
                For i = 1 To 99


                    Dim strint = i.ToString

                    If i.ToString.Length <= 1 Then

                        Prefix += "0" + i.ToString()



                        ListBox1.Items.Add(Prefix)


                        Prefix = Prefix.Substring(0, 2)
                    Else
                        Prefix += i.ToString()
                        ListBox1.Items.Add(Prefix)
                        Prefix = Prefix.Substring(0, 2)
                    End If
                Next
            Loop


        Else



        End If

        Dim FileNumber As Integer = FreeFile()
     

     

        FileOpen(FileNumber, "C:\Documents and Settings\V-CM\Desktop\Validate.txt", OpenMode.Output)
        For Each Item As Object In ListBox1.Items
            strSQL = "INSERT INTO cciown.cciPOGNumber(cciown.cciPOGNumber.POG_NBR)VALUES (" + Item.ToString + ")"""
            Dim cmd As New OracleCommand(strSQL, oonConn)
            Try
                cmd.CommandType = CommandType.Text

                cmd.ExecuteNonQuery()


            Catch ex As Exception
            End Try

            PrintLine(FileNumber, Item.ToString)

        Next
        PrintLine(FileNumber, " the Total Number of validated records is")
        PrintLine(FileNumber, ListBox1.Items.Count)
        FileClose(FileNumber)
        oonConn.Close()


    End Sub

 

End Class


Viewing all articles
Browse latest Browse all 27184

Trending Articles