Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dim obj As dataset = New dataset
VB
Dim balrow As DataRow = obj.Tables("openacc").NewRow()//error at this line saying Object reference not set to an instance of an object.
                                        balrow("name") = fname
                                        balrow("address") = fulladdress
                                        balrow("oldacno") = oldno
                                        balrow("status") = statusname
                                        balrow("nomineeno") = nomineeno
                                        balrow("opendate") = open_date
                                        balrow("fromdate") = frdate
                                        balrow("todate ") = todate
                                        balrow("fglhead") = fglhead
                                        balrow("open") = open
                                        obj.Tables("openacc").Rows.Add(balrow)

i am inserting value into dataset but its giving error:-
//Object reference not set to an instance of an object.//
Posted

The table openacc does not exist.. Create it first, and declare each column before trying to create a new row.
 
Share this answer
 
Comments
lakshjoshi 28-Jan-15 6:20am    
aah! right..spelling mistake of openacc i decaired opnacc..thank you..nice catch..excellent...
I suspect that you haven't setup the dataset and data table properly.

have a look at this Adding a DataTable to a DataSet (ADO.NET)[^]. It shows a short code example of how to create it.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900