briangriffin
Programmer
Database guy here, not the programmer - he's sharp but not too experienced with asp.net.
He's created a page with a datagrid, the users are able to update records based on security in an entitlement table.
The select works fine, and the update works fine except we want to update a database field with the username of the person making the update. Sounds easy since we're successfully passing that value into the select statement to return the appropriate rows to be updated.
Anyway, here's the code so if you have any ideas I'd be most appreciative.
Also, the error refers to inability to insert a null value into the table, which is correct - that field is not nullable. But that implies that no value is being assigned to the variable in the update statement.
He's created a page with a datagrid, the users are able to update records based on security in an entitlement table.
The select works fine, and the update works fine except we want to update a database field with the username of the person making the update. Sounds easy since we're successfully passing that value into the select statement to return the appropriate rows to be updated.
Anyway, here's the code so if you have any ideas I'd be most appreciative.
Code:
SelectCommand="select
d.recordnumber,
a.acctunit as 'Accounting Unit',
b.unitdescription as 'Unit Description',
c.datadescription as 'DataDescription',
case when d.datavalue is null then 0 else d.datavalue end as 'Value'
from
dbo.Productivity_Security a inner join dbo.Lawson_AccountingUnits b
on a.acctunit = b.acctunit
left outer join dbo.Productivity_DataDescription c
on a.acctunit = c.acctunit
left outer join dbo.Productivity_DataEntry d
on c.acctunit = d.acctunit
and c.datadescriptionid = d.datadescriptionid
where
a.username = @v_user -- here's where the username is passing properly
and d.datadate = @v_date
order by a.acctunit, c.datadescriptionid"
UpdateCommand="update productivity_dataentry
set [datavalue] = @Value,
[username] = 'testdomain\testuser', -- passing in hardcoded value for testing
[updatetime] = getdate()
where [recordnumber] = @original_recordnumber" >
Also, the error refers to inability to insert a null value into the table, which is correct - that field is not nullable. But that implies that no value is being assigned to the variable in the update statement.