Insert current date into a field [closed]

1

I am using% co.de% of .Net to create a project as a learning base for BD with C #. I chose an easier way that would be to work most of the time in design mode through dataAdapters . The battle I face is to insert the current date into a DB field. The following code works fine with strings for the text fields and Datasets for the 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 int but I do not know how to adapt to this format without having to change all the code.

The exception message follows:

  

An unhandled exception of type System.FormatException occurred in mscorlib.dll

     

Additional information: The input string was not in a correct format.

    
asked by anonymous 13.12.2015 / 02:51

1 answer

2

The only method used in this snippet that produces this exception is Int32.Parse , then the problem certainly lies in the content of the existing comboboxes variables. What you have in them should be possible to convert to an integer.

I would advise against using obsolete technologies such as TableAdapter and Access.

    
13.12.2015 / 05:12