Subject: Help please: another beginner's question
Posted By: savoym Post Date: 1/9/2004 10:14:45 AM
I am getting the following error from my FORM code:

'Cannot implicitly convert type 'int' to 'string' which refers to the following line of code in my FORM code:

lblCount.Text  = il.load( Convert.ToInt16(lstringClientID), lintMonthText, Convert.ToInt16( lstringYearText ));


My FORM code:

private void btnInvoiceSearch_Click(object sender, System.EventArgs e)
{
    Cursor.Current = Cursors.WaitCursor;

// Identify the variables from the form elements to pass to the stored procedure in the PSSBilling_WebService
    string lstringClientID = txtClientID.SelectedText;
    int lintMonthText = lstMonthText.SelectedIndex + 1;
    string lstringYearText = lstYearText.SelectedItem.ToString();

    InvoiceList il = new InvoiceList();
    lblCount.Text  = il.load( Convert.ToInt16(lstringClientID), lintMonthText, Convert.ToInt16( lstringYearText ));
}

My LOAD code from another class within my same project:

public int load (int astringClientID, int aintMonthText, int astringYearText)
{
    iintClientid = astringClientID;
    iintMonth = aintMonthText;
    iintYear = astringYearText;

// Connect to the PSSBilling_WebService
    PSSBilling.Service1  wsSearch = new PSSBilling.Service1();
    idsInvoices = new DataSet();
    idsInvoices = wsSearch.getInvoiceDataByClient( astringClientID, aintMonthText, astringYearText );

    return idsInvoices.Tables[dsReturnedData].Rows.Count;
}
Reply By: KABay Reply Date: 1/9/2004 10:45:56 AM
The Load method return an integer:

public int load (int astringClientID, int aintMonthText, int astringYearText)

Your call to it is trying to stuff the result (an integer) into a string. You need to convert the int to a string:

lblCount.Text  = Convert.ToString(il.load( Convert.ToInt16(lstringClientID), lintMonthText, Convert.ToInt16( lstringYearText )));

or

lblCount.Text  = il.load( Convert.ToInt16(lstringClientID), lintMonthText, Convert.ToInt16( lstringYearText )).ToString();




Go to topic 8312

Return to index page 972
Return to index page 971
Return to index page 970
Return to index page 969
Return to index page 968
Return to index page 967
Return to index page 966
Return to index page 965
Return to index page 964
Return to index page 963