I have a development where i made a Com dll to communicate with Centura SQLBase:
COM DLL Code
adaptor.SelectCommand() = New SQLBaseCommand("SELECT COMPANY_ID,COMPANY_NAME FROM COMPANY", myConnection)
Dim ds = New DataSet()
adaptor.Fill(ds, "COMPANY")
Dim myArray As New ArrayList
For Each row As DataRow In ds.Tables(0).Rows
myArray.Add(row)
Next
MsgBox(myArray(1).Item(0)) //This shows 102
MsgBox(myArray(1).Item(1)) //This shows Maui Mu-Mus
Return myArray
So myArray
is storing the right values; however in my MVC Controller i got an arrayList with 23 rows(which is fine) but all of them empty.
Here is my Controller Code GET: /Gupta/GetCiudades
Function GetCiudades() As JsonResult
Dim objConn As Object
objConn = Server.CreateObject("TestGupta.ComClass1")
Dim ciudadJson As ArrayList = objConn.getCompanies()
Return Json(ciudadJson, JsonRequestBehavior.AllowGet)
End Function
Ajax Code
:
$.getJSON("Gupta/GetCiudades", null, function (ciudades) {
ciudades = (JSON.stringify(ciudades));
console.log(ciudades);
});
console.log Result:
[{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
The question is: if in the com object is showing the right values, then why in the controller the rows are empty??
Fixed:
Com+ Code:
Controller Call
Solution based on ArrayList of Objects in the controller, and now the Com method returns a Dataset.