Last post May 12, 2010 12:14 PM by chorofonfilo
May 11, 2010 05:36 PM|chorofonfilo|LINK
Hello to everyone on the forums.
I am trying to use the updatedataset method from the enterprise library 2.0 and i am having some problems with that.
The code to do so didn't work in my app so i just created a test app to test this and i am getting the same result.
I created a table with two fields id_up,num_up this is the procedure that handles the record updating task.
create procedure updnum
@outi int output
Update deltb set num_up=num_up + 'text'
This is the function to update the record in my DAL.
Public Function UpdateNumber(ByVal ds As DataSet, ByVal idNum As Short) As Short
Dim intEstope As Integer = -1
Dim db As Database = DatabaseFactory.CreateDatabase
Dim dbCommand As DbCommand = db.GetStoredProcCommand("updnum")
db.AddInParameter(dbCommand, "@idb", DbType.Int16, idNum)
db.AddOutParameter(dbCommand, "@outi", DbType.Int16, Nothing)
db.UpdateDataSet(ds, "numbers", Nothing, dbCommand, Nothing, UpdateBehavior.Standard)
intEstope = CInt(db.GetParameterValue(dbCommand, "@outi"))
When i execute this i get an Exception while trying to convert the "@outi" parameter to CInt because the resulting value is DBNull which is odd considering that it's being initialized on the stored procedure with the number 8888
I have ran the stored procedure separately and it works well, also the dataset passed has data as i have confirmed reporting its number of rows before executing the updatedatabase method.
I don't understand well whats going on here.
If you could give me some insight i would really appreciate it.
Enterprise Libraries 2006
May 12, 2010 01:22 AMemail@example.com|LINK
use Int32 rather than Int16
db.AddInParameter(dbCommand, "@idb", DbType.Int32, idNum)
db.AddOutParameter(dbCommand, "@outi", DbType.Int32 0);
result = db.ExecuteNonQuery(dbCommand);
intId = Convert.ToInt64(db.GetParameterValue(dbCommand, outi));
try this rather than db.UpdateDataSet
hope this will help you.
May 12, 2010 12:14 PM|chorofonfilo|LINK
Thats not exactly what i am trying to accomplish, i would like to avoid the use of a sqlcommand to update the record this way, i would like to use explicitly the dataset, update it directly and being able to trace the success of the operation after passing
it against the database with the output parameter that for some reason returns null using the enterprise library UpdateDataset method.
I will keep looking for a way to perform this.
Thanks a lot for your help.