Click here to Skip to main content
11,582,850 members (69,131 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: 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 20:25pm
Edited 30-Aug-12 20:33pm
Mehdi Gholam280.9K
ryanb31 at 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 at 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
0 OriginalGriff 315
1 Sergey Alexandrovich Kryukov 220
2 Andy Lanng 124
3 virusstorm 119
4 Kornfeld Eliyahu Peter 100
0 OriginalGriff 1,403
1 Sergey Alexandrovich Kryukov 970
2 Abhinav S 696
3 F-ES Sitecore 505
4 Suvendu Shekhar Giri 503

Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 10 Jan 2013
Copyright © CodeProject, 1999-2015
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