Click here to Skip to main content
12,829,079 members (39,347 online)
Rate this:
Please Sign up or sign in to vote.
See more: VB Oracle VB.NET
Respected all,
I am trying to insert values in oracle using my application but when i run my application then i got following error message
"Object reference not set to an instance of an object."

if i use new keyword to "dim dsNewRow As New DataRow" then i got following error message
"Error	2	'System.Data.DataRow.Protected Friend Sub New(builder As System.Data.DataRowBuilder)' is not accessible in this context because it is 'Protected Friend'."

what i can do please help me
Following is my code
sql = "select * from shift_detail";
        ds = New DataSet
        da = New OracleDataAdapter(sql, cn)
        da.Fill(ds, "save")
        Dim cb As New OracleCommandBuilder(da)
        Dim dsNewRow As DataRow

        dsNewRow = ds.Tables("save").NewRow()

        dsNewRow.Item("shift_no") = newno("Select max(shift_no) from shift_detail")
        dsNewRow.Item("shift_nm") = shift_name
        dsNewRow.Item("edate") = dt
        dsNewRow.Item("status") = "R"
        dsNewRow.Item("code") = shift_code

        da.Update(ds, "save")
Posted 30-Aug-12 21:25pm
Updated 30-Aug-12 21:33pm
Mehdi Gholam333.8K
ryanb31 31-Aug-12 8:33am
You need to find which line of code is give you the first error. It's just telling you something is not set yet or you are trying to access a column that is not there.
Avi Mali 31-Aug-12 9:02am
when my debugger is going to ds.Tables("save").Rows.Add(dsNewRow) line that time firs error is occur. My all column names are correct.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Try this, it might help
Public Function InsertData(ByVal SQLString As String) As Integer
 strErrorMessage = ""
        Dim objCmd As OracleCommand = New OracleCommand
            NoofRowsAffected = objCmd.ExecuteNonQuery
            Return NoofRowsAffected
        Catch ex As Exception
            strErrorMessage = "Message :" & ex.Message
            Return Nothing
            If Not IsNothing(objCmd) Then
                objCmd = Nothing
            End If
End Function


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100