Sửa lỗi the dataadapter select command property needs tobe initialized năm 2024
First things first, get rid of the line that's throwing the exception. There is absolutely no point calling GetInsertCommand and assigning the result manually to the DataAdapter's InsertCommand if you aren't going to make any changes to it. If you're not going to make any changes to the command, e.g. enlist it in a transaction, then you should simply call Update on the DataAdapter and let the rest happen automatically. That said, the CommandBuilder is not magic. It can't generate an INSERT statement with no knowledge of the table and columns being inserted into. In order to use a CommandBuilder with a DataAdapter, the DataAdapter's SelectCommand must contain a SQL SELECT statement. Only by your specifying where the data has originally come from can the CommandBuilder know where the new data is going to. 'Inline Code Example HereHello i'm having this error message when adding to multiple table: '"The DataAdapter.SelectCommand property needs to be initialized." 'I need to have my data saved into both table(tblStudentInfo, tblPayment) when btnFinish clicked. Please 'help, i'm working on this for days and haven't had any luck. 'For reference i attached codings below (frmMainMenu_load, btnFinish):
This is what I was following, so either it is wrong or I have something in the wrong place. It doesn't suggest creating a command other than the CommandBuilder which I did .... so either the SQL statement I provided is wrong or I've done something else to muck it up. All I wanna do is add some records and save it back to the DB. When I googled this error I was given a lot of C# examples. That doesn't help me in this situation.
|