Multiple-step OLE DB operation generated errors

Unanswered Multiple-step OLE DB operation generated errors

  • Monday, February 11, 2013 3:49 AM
     
     

    public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (CategoryLB.Items.Count == 0)//To prevent duplicate items
                {
                    //Connect to database 
                    OleDbConnection conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\vincent\\Desktop\\Database41.accdb");
                    conn.Open();

                    //SQL query to retrieve all book titles from DB
                    OleDbCommand cmd = new OleDbCommand("SELECT Category FROM Category_Table", conn);
                    OleDbDataReader reader = cmd.ExecuteReader();
                    CategoryLB.Items.Add("All");
                    //Populate the titles listbox with titles.
                    while (reader.Read())
                    {
                        CategoryLB.Items.Add(reader.GetString(0));

                    }

                    //Close database connection 
                    reader.Close();
                    conn.Close();

                }
            }

            protected void Button1_Click(object sender, EventArgs e)
            {
                string gameSelected = this.CategoryLB.SelectedValue;
                retrievegames(gameSelected);
            }
            protected void retrievegames(string categorySelected)
            {
                if (CategoryLB.SelectedValue == "All") {
                    OleDbConnection option2 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\\Users\\vincent\\Desktop\\Database41.accdb");
                    option2.Open();

                    //Get the ID of the selected game
                    OleDbCommand cmd = new OleDbCommand("SELECT Title FROM GameList", option2);
                    OleDbDataReader reader = cmd.ExecuteReader();
                    //Populate the titles listbox with titles.
                    while (reader.Read())
                    {

                        GameList.Items.Add(reader.GetString(0)); //Fill in the first column with Game Title since Game Title is needed only
                    }

                    //Close database connection 
                    reader.Close();
                    option2.Close();
                }
                else
                {

                    //Connect to database 
                    OleDbConnection option2 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\\Users\\vincent\\Desktop\\Database41.accdb");
                    option2.Open();

                    //Get the ID of the selected game
                    OleDbCommand cmd = new OleDbCommand("SELECT Category_ID FROM Category_Table where Category= @category", option2);
                    cmd.Parameters.AddWithValue("@category", categorySelected);
                    OleDbDataReader reader = cmd.ExecuteReader();
                    reader.Read();
                    int categoryID = reader.GetInt32(0);
                    cmd = new OleDbCommand("SELECT Title from GameList where Category_ID=@category_id", option2);
                    cmd.Parameters.AddWithValue("@category_id", categoryID);
                    reader = cmd.ExecuteReader();
                    GameList.Items.Clear(); //Clear the games listbox first

                    //Put the games into the game listbox
                    while (reader.Read())
                    {
                        GameList.Items.Add(reader.GetString(0));//Fill in the first column with Description since Description is needed only
                    }
                    //Close database connection 
                    reader.Close();
                    option2.Close();
                }
            }

            protected void GameList_SelectedIndexChanged(object sender, EventArgs e)
            {
                OleDbConnection option3 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\\Users\\vincent\\Desktop\\Database41.accdb");
                option3.Open();

                //Get the ID of the selected movie
                OleDbCommand cmd = new OleDbCommand("SELECT Description FROM GameList where Title= @title", option3);
                cmd.Parameters.AddWithValue("@title", option3);
                OleDbDataReader reader = cmd.ExecuteReader();        < --------------------------------------This is the problem

    {"Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."}




                DescriptionBox.Items.Clear(); //Clear the review listbox first

                //Put the reviews into the review listbox
                while (reader.Read())
                {
                    DescriptionBox.Items.Add(reader.GetString(0));//Fill in the first column with Game Guide since Game Guide is needed only
                }
                //Close database connection 
                reader.Close();
                option3.Close();
            }
        }

    This my whole list of codes excluding database

All Replies

  • Monday, February 11, 2013 2:27 PM
     
     

    Hi,

    See if this link from a similar post helps you until an MVP or MSFT Eng replies. I was not able to recreate this error in my test environment.

    http://social.msdn.microsoft.com/Forums/is/accessdev/thread/37d51163-faf0-4966-852d-1ee72c66a218

    Frank.


    Frank Garcia