I have been trying out the ADO.net lesson 13 (http://www.programmersheaven.com/2/Les_VBNET_13_p1
) on this site and have a problem I can't seem to overcome.
I adapted the solution to the "food for thought" exercise #5
. Here is the link for the source code:http://www.programmersheaven.com/articles/faraz/vbnet/lesson14/DBAppWithBothTables_Q5.zip
I adapted the solution from SQLServer to Access OLEDB. I am using my own DB instead of the programmersHeaven db (which I couldn't find on this site...), so i changed names of variables and tables, but I have basically kept the same structure intact.
The problem I am having is with InitializeCommands() which is meant to initialize the insert, update and delete SQL commands. When I run the program I get a NullReferenceException unhandled error. (Reference to object not established as an instance of an object). The line of code that throws the error is:
dataAdapterEvento.UpdateCommand = conn.CreateCommand()
(although I get the same error with DeleteCommand or InsertCommand too)
After I got the error I moved the call to InitializeCommands() to btnEditRecord_Click I am able to connect to the db, fill the dataset and navigate between records as I should be able to...so I would think that there is not a Null reference here...conn and dataAdapter are good because otherwise I wouldn't see any data. (both of them are btw are declared like this:
Public Class ADOForm
Private conn As OleDb.OleDbConnection
Private dataAdapterEvento As OleDb.OleDbDataAdapter
Any ideas out there as to why this doesn't work?
0 · ·