HelpDeskAdapter

Hello.
I’m working on a customization where I need to use HelpDeskAdapter. I want to get info about case with specific ID. Then get CaseTypeID and use it later on. My code looks like that:

int number = 20; //sample case that exists
HelpDeskAdapter hdcAdapter = new HelpDeskAdapter(this.oTrans);
hdcAdapter.BOConnect();
hdcAdapter.GetByID(number);
string caseType = hdcAdapter.HelpDeskData.HDCase[0]["CaseTypeID"].ToString();
//this doesn't work also
//string caseType = hdcAdapter.HelpDeskData.HDCase.Rows[0]["CaseTypeID"].ToString(); 
hdcAdapter.Dispose();

I’m guessing the problem is in GetByID method. I don’t know if I’m missing any additional parameters and/or doesn’t that function return proper data because I’m getting error.
image

Could anyone help?

Chances are your routine is getting called before there’s any record or the case ID does not exist. You may want to wrap your code to test the count in your HelpDeskData set before calling your code.

I copied your code to a button event and it works exactly as I pasted it. I only added a button, and a message box to see the string. So, are you sure that you have a case 20, and are you sure this code is what’s causing the error? Secondly, have you tried using the BLTester to test out your calls? You can use that to make sure that your adapter calls are actually getting back something, and you can see what parameters are required.

	private void GetByIdButton_Click(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		int number = 1; //sample case that exists
		HelpDeskAdapter hdcAdapter = new HelpDeskAdapter(this.oTrans);
		hdcAdapter.BOConnect();
		hdcAdapter.GetByID(number);
		string caseType = hdcAdapter.HelpDeskData.HDCase[0]["CaseTypeID"].ToString();
		MessageBox.Show(caseType);
		//this doesn't work also
		//string caseType = hdcAdapter.HelpDeskData.HDCase.Rows[0]["CaseTypeID"].ToString(); 
		hdcAdapter.Dispose();
	}

image

image

1 Like

My sample Case ID exists of course.
When I called Count it returned 0

hdcAdapter.HelpDeskData.HDCase.Count(); // --> 0

I found BLTester and It gives me data back.
problem is somewhere in code.

I found the solution.
It must be Int32 going to the GetByID method as parameter.
Then Adapter’s DataSet will be populated.