I created a simple VB.Net program and am now trying to get it to input data into a Microsoft Access 2002 database. My main issue at this point is trying to work with the differences between writing ALL the code to do the work and using ADO.Net to do alot of the work(I am a beginner and have been using reference books for this learn this).
I started simple, just trying to insert 3 fields from my VB.Net program(public variables FirstName,LastName,MInitial) into the appropriate columns in the database(FName,LName,MName). Set up a OleDbConnection, OleDbDataAdapter and Dataset objects on my form and configured the adapter with the Configuration Wizard. My code is this:
OleDbConnection1.Open()
OleDbDataAdapter1.Fill(Dataset1)
OleDbDataAdapter1.InsertCommand.ExecuteNon Query()
OleDbDataAdapter1.Update(DataSet1)
OleDbConnection1.Close()
Visual Studio code editor does not object to any of the above, but I get an exception error at the third line. My questions are:
1) Am I correct in my understanding that the DataAdapter object automatically takes care of the underlying code associated with its Insert and Update commands(as long as its Command type and Command text are properly set) and therefore can be used to insert a record into a database?
2) If #1 is true, are the changes I make to the DataAdapter's Insert and Update commands via it's Properties window persistent(ie- will they remain in effect each time the program is run or are they reset to defaults after execution)?
3) I am assuming Public variables from my VB.Net program can be inserted into the SQL Insert and Update statements to transfer their values to the database. Is this true?
Thanks in advance for any help. I have read my VB.Net and ADO books over and over and still unsure of the above three!
MRC