Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 9th, 2004, 11:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 119
Thanks: 0
Thanked 1 Time in 1 Post
Default Help please: another beginner's question

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;
}
 
Old January 9th, 2004, 11:45 AM
Authorized User
 
Join Date: Nov 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to KABay
Default

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();





Similar Threads
Thread Thread Starter Forum Replies Last Post
A beginner's question Gene Reginato XSLT 5 May 17th, 2007 10:32 AM
Beginner's Question peytontodd Beginning VB 6 3 March 7th, 2007 11:58 AM
Beginner's question re: WindowsForm DataGrid savoym C# 2 January 19th, 2004 02:51 PM
Beginner's question savoym C# 2 January 8th, 2004 03:58 PM
Beginner's SQL question pankaj_daga SQL Language 3 November 12th, 2003 07:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.