=OTS=G-Man 26 Light Poster

mysql_fetch_array() returns an array with indexes, not field names.

You can pass the optional paramater MYSQL_ASSOC like so, mysql_fetch_array($result, MYSQL_ASSOC)

or you may use mysql_fetch_assoc() and that will return the array with field names.

Hope it helps.

=OTS=G-Man 26 Light Poster

Hello everyone. I have a question here, that to me seems there must be a way to do what I want in the way I want :)

I have a thing that updates a Zen Cart DB and adds products to it.

Ok everything works the way it is now, but It close the connection to the DB after each item, is there a way to prevent this?

Little background and code

I originally tried to just null out my command but afte the first one I would get "There is already an open DataReader associated with this Connection which must be closed first."

so I searched around the internet and found something where they set the dataReader to close the connection, At that point it works, but as I said before, it disconnects and has to reconnect every item.

here is the code with before and after. any ideas would be great.

//** = points of interest

the SQL statement is 3 INSERT statements hence why i didn't have a DataReader Object originally

private static void AddZenCartItem(Product item)
        {
            Log.WriteLine("Im adding "+item.Description+" to the zencart.");

            String sql;

            //Now lets put some SQL in that String
            sql = //BIG LONG SQL STATEMENT 
            
            //Reopen the connection just incase it closed
            if (MyConn.State != ConnectionState.Open)
                MyConnect();

            MySqlCommand command = MyConn.CreateCommand();

            //**Added from the internet fix
            MySqlDataReader dataReader = null;

            try
            {
                command.CommandText = sql;
                
                //Fill in them infos
                command.Parameters.Add(new MySqlParameter("?product_id", item.SKU));
                command.Parameters.Add(new MySqlParameter("?products_model",