hey,
does anyone know how to handle this exception?

please help me

//Retrieves all the contract numbers from the Contract table
        public String[] getPhaseNumbers(String TopicNo)
        {
            db.openConnection();

            String query = @"Select Phase From Topic Where TopicNo = @topicNo";
            SqlCommand command = new SqlCommand(query, DB.getConnection());

            command.Parameters.Add("@topicNo",SqlDbType.Int).Value = TopicNo;

            SqlDataAdapter da = new SqlDataAdapter(command);
            DataTable dt = new DataTable();

[B]            da.Fill(dt);
[/B]
            int NoOfRows = dt.Rows.Count;
            String[] phase = new String[NoOfRows];


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                phase[i] = dt.Rows[i]["Phase"].ToString();

            }

            db.closeConnection();

            return phase;

        }

from the place the code is bolded it says "Failed to convert parameter value from a String to a Int32."

why is this
w@ is the solution for this ?

please give me an answer?
thankxxxxxxxxxx

Don't see any bolded code, could ou be more specific?

change

command.Parameters.Add("@topicNo",SqlDbType.Int).Value = TopicNo;

with

command.Parameters.Add("@topicNo",SqlDbType.Int).Value = Int32.Parse(TopicNo);

Hope this helps.

Ionut

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.