.NET Libraries / Parameter Names and Compound Keys

.NET Libraries / Parameter Names and Compound Keys

ServiceSoftwareServiceSoftware Posts: 5Questions: 2Answers: 0

https://editor.datatables.net/manual/net/getting-started points out that "This can be useful if you wish to obfuscate the SQL columns names so the client will never see the actual database naming, or simply want to reduce the size of the JSON object transmitted to the client." Yes!

But this seems not to work with Compound Keys, which fails in Create with an error: Object reference not set to an instance of an object.

This controller code causes the error:


Dim arrKeys(2) As String arrKeys(0) = "field_one" arrKeys(1) = "field_two" arrKeys(2) = "field_three" obj_Editor = New Editor(db, "table_comp", arrKeys) With obj_Editor .Field.Add(New DataTables.Field("field_one", "f0")) .Field.Add(New DataTables.Field("field_two")) .Field.Add(New DataTables.Field("field_three")) .Field.Add(New DataTables.Field("field_four")) .Process(HttpContext.Current.Request) End With

This controller code does work ...


Dim arrKeys(2) As String arrKeys(0) = "field_one" arrKeys(1) = "field_two" arrKeys(2) = "field_three" obj_Editor = New Editor(db, "table_comp", arrKeys) With obj_Editor .Field.Add(New DataTables.Field("field_one")) .Field.Add(New DataTables.Field("field_two")) .Field.Add(New DataTables.Field("field_three")) .Field.Add(New DataTables.Field("field_four")) .Process(HttpContext.Current.Request) End With

Interestingly, the SQL Trace does show execution of a statement that will create the row of data in the table without error:

exec sp_executesql N'DECLARE @T TABLE ( insert_id varchar (50) ); INSERT INTO [table_comp] ( [field_one], [field_two], [field_three], [field_four] ) OUTPUT INSERTED.FIELD_ONE as insert_id INTO @T VALUES ( @field_one, @field_two, @field_three, @field_four ); SELECT insert_id FROM @T',N'@field_one nvarchar(1),@field_two nvarchar(1),@field_three nvarchar(1),@field_four int',@field_one=N'x',@field_two=N'y',@field_three=N'z',@field_four=7

But apparently the .NET Libraries rolls back after encountering "Object reference not set to an instance of an object." because the row of data is actually not inserted.

Replies

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    Hi,

    Could you confirm what version of the dll you are using for me please? If not 1.8.0 could you update to that please?

    Thanks,
    Allan

This discussion has been closed.