EFileTahi-A Posted February 3, 2005 Posted February 3, 2005 In my Access database there are predefined values for the new records. If I use "INSERT INTO" keyword the these predefined values will be applyed, but, when I add a new row to my DataTable and give it the order to update, none of these predefined values are put in the new row / record, they all become NULL... Can I force it to use the predefined values when adding a row to a DataTable and saving it (DataTable.Update) to the database? Quote
EFileTahi-A Posted February 4, 2005 Author Posted February 4, 2005 If this is not explicit, please, drop a line... I will re-write it tks Quote
Optikal Posted February 4, 2005 Posted February 4, 2005 What are you using for the InsertCommand on your DataAdapter? Quote
EFileTahi-A Posted February 6, 2005 Author Posted February 6, 2005 What are you using for the InsertCommand on your DataAdapter? What do you mean? I don't think am using none of that in my DataAdapter... Quote
EFileTahi-A Posted February 7, 2005 Author Posted February 7, 2005 Mmm, I think I know what you are trying to say... Could you show me how to use "insert into" keyword on an DataAdapter Quote
Optikal Posted February 7, 2005 Posted February 7, 2005 Well there is no Update() method on the DataTable object (which is what you said you were doing). I assumed you were using a DataAdapter to write the changes back to your database in which case you need to have the InsertCommand, UpdateCommand, and/or DeleteCommand set appropriately so it knows how to properly write your changes back. Your help files have plenty of documentation and samples as to how this should be done, there is even a wizard to create a DataAdapter that will build the commands for you. Quote
EFileTahi-A Posted February 9, 2005 Author Posted February 9, 2005 (edited) Well there is no Update() method on the DataTable object (which is what you said you were doing). I assumed you were using a DataAdapter to write the changes back to your database in which case you need to have the InsertCommand' date=' UpdateCommand, and/or DeleteCommand set appropriately so it knows how to properly write your changes back. Your help files have plenty of documentation and samples as to how this should be done, there is even a wizard to create a DataAdapter that will build the commands for you.[/quote'] Am using OleDbCommandBuilder with the OleDbDataAdapter in order to store change/add info back to the Access database... Does this make a diference? Cooze Am truly noob with data bases in .NET... Am searching both web and MSN library for info, but so far, am only collecting pieces, don't have the skills to assemble them to solve the puzzle... PS: Am getting truly confused with all this... Is there any kind soul who could post me an short example showing me the proper way of using insert command on DataAdapter... This is my code to get you started in case you want to post some sample code: DataTable dtInCCCli = Data2.InCCCli(); OleDbDataAdapter daInCCCli = dbEngine.getDataAdapter(); OleDbCommandBuilder cbInCCCli = new OleDbCommandBuilder(daInCCCli); newRow = dtInCCCli.NewRow(); newRow["numero"] = dtFindCli.Rows[0]["numero"].ToString(); newRow["numdoc"] = this.txt_numDoc.Text; newRow["coddoc"] = "FA"; newRow["descri"] = "Factura Nº" + this.txt_numDoc.Text; newRow["db"] = dTotalSum; dtInCCCli.Rows.Add(newRow); daInCCCli.Update(dtInCCCli); Edited February 9, 2005 by EFileTahi-A Quote
EFileTahi-A Posted February 18, 2005 Author Posted February 18, 2005 Althought this thread issue was not resolved or received any further support for too long I will now declare that it is no longer active since I moved to mySQL and there is not the "null values" problem thing... - THREAD CLOSED - Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.