0
        protected double[] getValues(int ColumnCount)
        {
            double[] value = new double[ColumnCount];

            SqlConnection conGetValue = new SqlConnection(ConfigurationManager.ConnectionStrings["connMSJ"].ConnectionString);
            SqlCommand cmdGetValue = new SqlCommand("(SELECT * FROM DailyBudget WHERE (Username=@username)) EXCEPT (SELECT Username FROM DailyBudget WHERE Username=@username)", conGetValue);
            cmdGetValue.Parameters.AddWithValue("@username", Master.getUsername);
            conGetValue.Open();
            SqlDataReader dtrGetValue = cmdGetValue.ExecuteReader();
            try
            {
                int i = 0;
                while (dtrGetValue.Read())
                {
                    value[i] = Convert.ToDouble(dtrGetValue[i]);
                    i++;
                }
            }
            finally
            {
                dtrGetValue.Close();
                conGetValue.Close();
            }

            return value;
        }

Where is my mistake? i want every columns value where Username = master.lblUsername but except the first column which is contain the username.

2
Contributors
2
Replies
9
Views
4 Years
Discussion Span
Last Post by gahhon
0

i want every columns value where Username = master.lblUsername but except the first column which is contain the username.

Do you mean that other columns may have the value of @username? your current syntax is only looking at the fied called "Username" and you are simply displaying all fields in the result.

in your EXCEPT, the reason for the error is that you have a mismatch of field names. in the first query you have more than field, where the second query only has one field.

0

First Query

Is used to select all (contain username, foods, drinks, and etc.)

Second Query

Is used to extract out the value of username

Thus, what should i do can extract username value instead of using multiple column field in the second query.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.