I am working on a code to implement an application. The error shows
The parameterized query'#original_controllerIP nvchar(19), #IsNull_ControllerName int' expects the parameter #IsNull_ControllerName which was not supplied.
I have tried adding Original_ControllerIPName and all other parameters for the controller but did not work.
public virtual int Delete(string Original_ControllerIP) {
if ((Original_ControllerIP == null)) {
throw new global::System.ArgumentNullException("Original_ControllerIP");
}
else {
this.Adapter.DeleteCommand.Parameters[0].Value = ((string)(Original_ControllerIP));
}
global::System.Data.ConnectionState previousConnectionState = this.Adapter.DeleteCommand.Connection.State;
if (((this.Adapter.DeleteCommand.Connection.State & global::System.Data.ConnectionState.Open)
!= global::System.Data.ConnectionState.Open)) {
this.Adapter.DeleteCommand.Connection.Open();
}
try {
int returnValue = this.Adapter.DeleteCommand.ExecuteNonQuery();
return returnValue;
}
finally {
if ((previousConnectionState == global::System.Data.ConnectionState.Closed)) {
this.Adapter.DeleteCommand.Connection.Close();
}
}
}
The parameters are like this:
this._adapter.DeleteCommand = new global::System.Data.SqlClient.SqlCommand();
this._adapter.DeleteCommand.Connection = this.Connection;
this._adapter.DeleteCommand.CommandText = #"DELETE FROM [ControllersData] WHERE (([ControllerIP] = #Original_ControllerIP) AND ((#IsNull_ControllerName = 1 AND [ControllerName] IS NULL) OR ([ControllerName] = #Original_ControllerName)) AND ((#IsNull_ControllerMac = 1 AND [ControllerMac] IS NULL) OR ([ControllerMac] = #Original_ControllerMac)) AND ((#IsNull_ControllerStatus = 1 AND [ControllerStatus] IS NULL) OR ([ControllerStatus] = #Original_ControllerStatus)))";
this._adapter.DeleteCommand.CommandType = global::System.Data.CommandType.Text;
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_ControllerIP", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerIP", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_ControllerName", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerName", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_ControllerName", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerName", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_ControllerMac", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerMac", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_ControllerMac", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerMac", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_ControllerStatus", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerStatus", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.DeleteCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_ControllerStatus", global::System.Data.SqlDbType.NVarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "ControllerStatus", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
Your query is expecting 2 parameters: original_controllerIP and IsNull_ControllerName, but you are only supplying one:
this.Adapter.DeleteCommand.Parameters[0].Value = ((string)(Original_ControllerIP));
You should provide both parameters:
this.Adapter.DeleteCommand.Parameters[0].Value = ((string)(Original_ControllerIP));
this.Adapter.DeleteCommand.Parameters[1].Value = VALUE IN HERE;
If your query should only accept one parameter, it's possible you need to refresh / update your data adapter
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
This is my string that I believe to be json output. I am getting
Expecting 'STRING', got '}'.
Can anyone help me to resolve this please?
{
"shipToAddress": {
"type": "ST",
"recordId": "ST",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"shipFromAddress": {
"type": "ST",
"recordId": "ST",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"addresses": [
{
"type": "ST",
"recordId": "ST",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
}
],
"orders": [
{
"recordId": "3",
"poNumber": "0006630041",
"items": [
{
"itemComponents": [
{
"itemNotes": [
{
"recordId": "",
"type": "",
"note": ""
}
],
"recordId": "3",
"lineNo": "3",
"sublineNo": "3",
"originalLineNo": "3",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "42",
"itemColor": "BLK/RED",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "405.46",
"priceBasis": "",
"sellingPrice": 995,
"discountPercent": 0,
"shipDate": 060419,
"packSize": 1,
"inners": 1,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": ""
}
],
"recordId": "",
"lineNo": "",
"sublineNo": "",
"originalLineNo": "",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "",
"itemColor": "",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "",
"priceBasis": "",
"sellingPrice": 0,
"discountPercent": 0,
"shipDate": 0,
"packSize": 0,
"inners": 0,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": "",
"extItemRef": "",
"custFld01Nam": "",
"custFld01Val": "",
"custFld02Nam": "",
"custFld02Val": "",
"custFld03Nam": "",
"custFld03Val": "",
"qtyShip": 0,
"qtyRemain": 0,
"itemPackCode": "",
"itemDimensionLength": 0,
"itemDimensionWidth": 0,
"itemDimensionHeight": 0,
"itemDimensionUom": "",
"cartonLenght": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"itemStatus": "AC",
"statusReason": "backorder_cancel",
"statusDesc": "",
"qtyBackorder": 0,
"backorderDate": 0
},
{
"recordId": "4",
"poNumber": "0006630041",
"items": [
{
"itemComponents": [
{
"itemNotes": [
{
"recordId": "",
"type": "",
"note": ""
}
],
"recordId": "4",
"lineNo": "4",
"sublineNo": "4",
"originalLineNo": "4",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "43",
"itemColor": "BLK/RED",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "405.46",
"priceBasis": "",
"sellingPrice": 995,
"discountPercent": 0,
"shipDate": 060419,
"packSize": 1,
"inners": 1,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": ""
}
],
"recordId": "",
"lineNo": "",
"sublineNo": "",
"originalLineNo": "",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "",
"itemColor": "",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "",
"priceBasis": "",
"sellingPrice": 0,
"discountPercent": 0,
"shipDate": 0,
"packSize": 0,
"inners": 0,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": "",
"extItemRef": "",
"custFld01Nam": "",
"custFld01Val": "",
"custFld02Nam": "",
"custFld02Val": "",
"custFld03Nam": "",
"custFld03Val": "",
"qtyShip": 0,
"qtyRemain": 0,
"itemPackCode": "",
"itemDimensionLength": 0,
"itemDimensionWidth": 0,
"itemDimensionHeight": 0,
"itemDimensionUom": "",
"cartonLenght": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"itemStatus": "AC",
"statusReason": "backorder_cancel",
"statusDesc": "",
"qtyBackorder": 0,
"backorderDate": 0
},
{
"recordId": "5",
"poNumber": "0006630041",
"items": [
{
"itemComponents": [
{
"itemNotes": [
{
"recordId": "",
"type": "",
"note": ""
}
],
"recordId": "5",
"lineNo": "5",
"sublineNo": "5",
"originalLineNo": "5",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "44",
"itemColor": "BLK/RED",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "405.46",
"priceBasis": "",
"sellingPrice": 995,
"discountPercent": 0,
"shipDate": 060419,
"packSize": 1,
"inners": 1,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": ""
}
],
"recordId": "",
"lineNo": "",
"sublineNo": "",
"originalLineNo": "",
"qty": 0,
"unitMeasure": "EA",
"upcCode": "",
"vendorNumber": "",
"unitSize": "",
"itemColor": "",
"customerItem": "",
"gtinNumber": "",
"upcCaseCode": "",
"prepackCode": "",
"caseGroupCode": "",
"skuNumber": "",
"unitPrice": "",
"priceBasis": "",
"sellingPrice": 0,
"discountPercent": 0,
"shipDate": 0,
"packSize": 0,
"inners": 0,
"itemDesc": "",
"itemWeight": "",
"itemReferenceId": 0,
"lotNumber": "",
"nrfSize": "",
"nrfColor": "",
"nrfDesc": "",
"unitSizeBuyer": "",
"itemColorBuyer": "",
"buyerStyleNo": "",
"countryOfOrigin": "",
"ticketType": "",
"mfgName": "",
"mfgCity": "",
"mfgCountry": "",
"extItemRef": "",
"custFld01Nam": "",
"custFld01Val": "",
"custFld02Nam": "",
"custFld02Val": "",
"custFld03Nam": "",
"custFld03Val": "",
"qtyShip": 0,
"qtyRemain": 0,
"itemPackCode": "",
"itemDimensionLength": 0,
"itemDimensionWidth": 0,
"itemDimensionHeight": 0,
"itemDimensionUom": "",
"cartonLenght": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"itemStatus": "AC",
"statusReason": "backorder_cancel",
"statusDesc": "",
"qtyBackorder": 0,
"backorderDate": 0
}
],
"cartons": [
{
"pack": [
{
"lineNo": 0,
"qtyPack": 0
}
],
"recordId": "35210369",
"cartonCode": "",
"cartonQty": 0,
"palletId": 0,
"cartonWeight": 0,
"cartonLength": 0,
"cartonWidth": 0,
"cartonHeight": 0,
"cartonUom": "",
"cartonGroupCode": "",
"packSlipNumber": "",
"trackingNumber": ""
}
],
"billToAddress": {
"type": "BT",
"recordId": "BT",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"remitToAddress": {
"type": "RE",
"recordId": "RE",
"locationNumber": "",
"companyName1": "",
"companyName2": "",
"address1": "",
"address2": "",
"address3": "",
"address4": "",
"city": "",
"state": "",
"postalCode": "",
"country": "",
"dunsNumber": "",
"dunsType": "",
"contactPhone": "",
"contactEmail": "",
"contactFax": "",
"contactOther": "",
"locationCode": "",
"consolidator": ""
},
"location": "0689",
"shipToLocation": "",
"releaseNumber": "",
"contractNumber": "",
"poType": "",
"poCategory": "",
"customerOrderNumber": "",
"customerOrderRef": "",
"promoteCode": "",
"salesOrderNumber": "",
"customerAccount": "",
"buyerAccount": "",
"buyerEmail": "",
"vendor": "",
"vendorNumberAp": "30",
"poDate": 0,
"requestedDeliveryDate": 0,
"departmentNumber": "0149",
"departmentDescription": "",
"invoiceNumber": "SI19-000001",
"invoiceDate": 20190528,
"detailLineCount": 0,
"orderCartons": 0,
"orderWeight": 0,
"orderVolume": 0
}
],
"pallets": [
{
"recordId": "",
"palletId": 0,
"palletCode": "",
"palletType": "1",
"cartonCount": 0,
"palletWeight": 0,
"totalWeight": 0,
"weightUom": "",
"palletLength": 0,
"palletWidth": 0,
"palletHeight": 0,
"palletUom": "",
"palletTiers": 0,
"palletBlocks": 0,
"packSize": 0,
"inners": 0
}
],
"appointmentNumber": "",
"billOfLading": "",
"carrierCode": "",
"carrierCustom": 0,
"carrierService": "CX",
"contactEmail": "",
"contactFax": "",
"contactName": "",
"contactPhone": "",
"containerCarrierCode": "",
"containerType": "2B",
"custWhsNumber": "",
"deliveryDate": 20190528,
"externalId": "",
"fobCode": "CC",
"fobLocation": "OR",
"fobText": "",
"importHandlingCode": "",
"importLocCode": "",
"importLocType": "",
"importUnLocCode": "",
"importVesselName": "",
"importVoyageNumber": "",
"masterBillOfLading": "",
"packCodeContainer": "",
"packCodeMaterial": "",
"proNumber": "",
"routingInstructions": "",
"sealNumber": "",
"shipDate": 20190528,
"shipmentId": "SH19-000001",
"shipMode": "",
"shipTime": "",
"tagId": 0,
"trailerNumber": "",
"transitTime": "",
"transitTimeType": "",
"transportTermsCode": "",
"transportTermsQual": "",
"vendor": "",
"vendorNumberAp": "30"
}
After looking at the data, it looks like their are two problems.
Your collection of orders and items are not closed.
The main json object is not closed.
Let's start with the Order and Item collection:
The item collection in the order with recordId 3 is not closed properly. This is resulting in the order with recordId 4 being a child of record 3's items. Additionally there is no closure to the order record itself (missing curly braces).
To fix this, place a square brace, then a curly brace, before the comma, at the end of the item properties.
Resulting in:
Now that we have the orders cleaned up, there are just a couple braces at the end of the file that need to be closed.
The order collection is missing its closing square brace, and the main json object is missing its closing curly brace:
Resulting in:
So, this fixes the structural issues. As #Gixabel mentioned, you also need to enclose all the instances of shipDate as stings, since they are representations of dates.
Overall goal: Trying to to have a button that displays on every row that closes a the ticket (changes open state column to 0 and updates the closeddate column with datetime).
Stuff done so far: I have the button being created and displaying with the dataset. However, I can't figure out for the life of me how to get to update only those two columns (openstate, closeddate).
I'm using the default query builts as much as possible which might be my problem.
In efferts to not make you read all of the code i'll put as little as possible. if you need more please let me know and i'll add all it if you want.. Newbie at this so just let me know what you need :).
xaml:
<DataGrid x:Name="dgtask" Background ="Black"
ItemsSource="{Binding}"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Title"
Binding="{Binding Path='taskTitle'}" />
<DataGridTextColumn Header="Description"
Binding="{Binding Path='taskDesc'}" />
<!-- Add your normal columns here -->
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="btnclose" Click="btnclose_Click">My button</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
behind code:
private void btnclose_Click(object sender, RoutedEventArgs e)
{
DateTime date1 = DateTime.Now;
_dsTaskTracker = new TimeTrackerDataSet();
_taTaskTracker = new TimeTrackerDataSetTableAdapters.taskTableAdapter();
_dtTaskTracker = new TimeTrackerDataSet.taskDataTable();
_taTaskTracker.Update("I can't figure out how to limit this to only the two columns");
}
It's not picking all of it right sorry for the sloppy mess
dataset code:
this._adapter.UpdateCommand.CommandText = #"UPDATE [dbo].[task] SET [taskTitle] = #taskTitle, [taskDesc] = #taskDesc, [creation] = #creation, [closed] = #closed, [taskOpen] = #taskOpen WHERE (([titleID] = #Original_titleID) AND ([taskTitle] = #Original_taskTitle) AND ((#IsNull_taskDesc = 1 AND [taskDesc] IS NULL) OR ([taskDesc] = #Original_taskDesc)) AND ((#IsNull_creation = 1 AND [creation] IS NULL) OR ([creation] = #Original_creation)) AND ((#IsNull_closed = 1 AND [closed] IS NULL) OR ([closed] = #Original_closed)) AND ((#IsNull_taskOpen = 1 AND [taskOpen] IS NULL) OR ([taskOpen] = #Original_taskOpen)));
SELECT titleID, taskTitle, taskDesc, creation, closed, taskOpen FROM task WHERE (titleID = #titleID)";
this._adapter.UpdateCommand.CommandType = global::System.Data.CommandType.Text;
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#taskTitle", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskTitle", global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#taskDesc", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskDesc", global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#creation", global::System.Data.SqlDbType.DateTime, 0, global::System.Data.ParameterDirection.Input, 0, 0, "creation", global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#closed", global::System.Data.SqlDbType.DateTime, 0, global::System.Data.ParameterDirection.Input, 0, 0, "closed", global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#taskOpen", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskOpen", global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_titleID", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "titleID", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_taskTitle", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskTitle", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_taskDesc", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskDesc", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_taskDesc", global::System.Data.SqlDbType.VarChar, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskDesc", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_creation", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "creation", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_creation", global::System.Data.SqlDbType.DateTime, 0, global::System.Data.ParameterDirection.Input, 0, 0, "creation", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_closed", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "closed", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_closed", global::System.Data.SqlDbType.DateTime, 0, global::System.Data.ParameterDirection.Input, 0, 0, "closed", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#IsNull_taskOpen", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskOpen", global::System.Data.DataRowVersion.Original, true, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#Original_taskOpen", global::System.Data.SqlDbType.Int, 0, global::System.Data.ParameterDirection.Input, 0, 0, "taskOpen", global::System.Data.DataRowVersion.Original, false, null, "", "", ""));
this._adapter.UpdateCommand.Parameters.Add(new global::System.Data.SqlClient.SqlParameter("#titleID", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 0, 0, "titleID", global::System.Data.DataRowVersion.Current, false, null, "", "", ""));
I have an application using the web api in c sharp. I have the following json, and i need to parse the
mobile_synch_tax_r
value to test for a condition. The issue is that while this method worked using a windows service, it is not working in the controller of the web api.
The relevant json is:
{"SYNC_DATA": {
"mobile_synch_tax_r": [
{
"idtax_registration":66,
"gender": "",
"title": "",
"name": "AK",
"home_address": "",
"state_of_origin": "A",
"home_town": "",
"local_government": "",
"occupation": "",
"company_name": "",
"office_address": "No",
"ministry": "",
"market": "",
"park": "",
"phone_number": "",
"email_address": "",
"photo_url": "",
"tax_id": "285",
"state": null,
"registered_by": "imported",
"biometric_status": 0,
"registration_type": 2,
"group_id": 100,
"taxpayer_password": "*6BB",
"tax_exempt": 0,
"active": 1,
"disability": "",
"rf1": 1,
"rf2": 1,
"rf3": 1,
"rf4": 1,
"rf5": 1,
"lf1": 1,
"lf2": 1,
"lf3": 1,
"lf4": 1,
"lf5": 1,
"registered_on": "2015",
"drivers_license_number": "",
"national_number": "",
"international_passport_number": "",
"company_rcc": "",
"workplace_category": "",
"office_lg": "",
"office_city": "n",
"parent_id": "",
"workplace_type": 0,
"marital_status": "",
"nationality": "u",
"vend_pin": 0,
"residential_address_status": "",
"dob": null,
"surname": "Ad",
"first_name": "",
"middle_name": "",
"utin": "",
"last_pw_reset_by": "",
"temp_reg": 0,
"company_size": "",
"business_commencement_date": null,
"proprietor_tax_id": "",
"business_ownership_type": "",
"has_subsidiary": false,
"subsidiary": false,
"subsidiary_of": "",
"n": "",
"locked": false,
"author": "",
"synch_status": false
}]}}
This is the code in the controller:
// POST api/ak
public HttpResponseMessage Post(HttpRequestMessage value)
{
var someText = value.Content.ReadAsStringAsync().Result;
Library.WriteErrorLog("Data Received" + someText);
var objects = JObject.Parse(someText);
Library.WriteErrorLog("Objects are" + objects);
if (objects != null)
{
foreach (KeyValuePair<String, JToken> app in objects)
{
var rootName = app.Key;
if (rootName == "mobile_synch_tax_r")
{"Have your way with me"}}
The code is not able to check if the
rootName=="mobile_synch_tax_r"
How am i missing it?
If you're just looking for value of the "mobile_synch_tax_r" property, you can use SelectToken to get it:
var mobile_synch_tax_r = objects.SelectToken("..mobile_synch_tax_r");
.. is the recursive descent operator, so this query searches the JSON object hierarchy for the first property named "mobile_synch_tax_r", and returns its value.