c# - Creating new datarow on a SQL Server with automized date from DBMS doesn't work -
hi i'm trying create new datarow on sql server. works pretty if transmit mat_dbdate column manually c# code.
heres example:
c# code:
private void buttonmaterialanlegen_click(object sender, routedeventargs e) { try { datarow dr = dsmaterial.tbl_material.newrow(); dr["mat_fk_lfr_id"] = comboboxlieferant.selectedvalue; dr["mat_fk_lag_id"] = comboboxlagerort.selectedvalue; dr["mat_name"] = textboxbeschreibung.text; dr["mat_dbdate"] = datetime.now; dsmaterial.tbl_material.rows.add(dr); tamaterial.update(dsmaterial); } catch (exception ex) { messagebox.show(ex.message); } }
but if want sql server add date automatically via getdate() command default doesn't work. got nonullallowedexception.
the mat_dbdate colum has following specifications:
[mat_dbdate] datetime2 (7) constraint [df_tbl_material_mat_dbdate] default (sysdatetime()) not null,
thank's help!
Comments
Post a Comment