3
I’m using dataAdapters
do . Net to create a project as a BD learning base with C#. I chose an easier path that would be to work most of the time in design mode through the Datasets
. The battle I face is to insert the current date into a BD field. The following code works well with strings for the text and int
for foreign key fields:
orcTableAdapter.Insert(Int32.Parse(comboBox2.ValueMember),datatime.Now, 0,Int32.Parse(comboBox1.ValueMember));
orcTableAdapter.Update(vorc2DataSet.Orcamento);
vorc2DataSet.AcceptChanges();
orcTableAdapter.Fill(vorc2DataSet.Orcamento);
I know there are ways to convert through Add.Parameters
but I don’t know how to adapt to this format without having to change all the code.
Follow the exception message:
An unhandled Exception of type System.Formatexception occurred in mscorlib.dll
Additional information: The input character string was not in a correct format.
Some things there indicate that you’re not learning the right way, especially if you’re worried about changing code if that’s necessary. But in this particular case these combobox must contain incompatible data to generate an integer. I cannot guarantee with so little information. While reading about this: http://answall.com/q/101691/101. Your problem doesn’t seem to be with Visual Studio.
– Maniero
Something tells me you haven’t read my question carefully either. The data of the combobox works perfectly, what does not work is my attempt to enter the date and time directly in the BD through the standard command for Visual Studio Forms (Datetime.Now). I’ve been trying to solve this detail for over 8 hours and all this time I’ve spent with reading. I still get there.
– Vanderlei