Hello,

So lately, I've been coming across this issue of mine and can't seem to find a solid way around this problem. My problem is due to the fact I'm using MYSQL C connector library. And, Attempting to gain all the Row's from my database and store them in a array. Well this is where I'm having the trouble. In order for me to extract the data from my DB I much use a character pointer to pointer. When it fetches the row(one at a time unfortunately). It rewrites it's array starting at 0. When I then try to take this array row[0] and attempt to store it in a different function. That new function, no matter what I do changes once it gains the new row, due to pointer to pointer.

Hopefully someone can point out what I need to do in order for this to stop happening.

Thanks,
-A2H

Recommended Answers

All 5 Replies

I'm almost certain you have to make a copy of the data to do what you're trying to do.

Depending on the database and the size thereof, attempting to load the entire database into an array might not be your wisest design decision.

Here are a few questions to help evaluate the design:

How much data are we talking about?

Do you have enough memory to store it all?

What are you going to do with the data once it is in the array?

What is the real benefit to having the data in the array versus just accessing the data in the database when you need it?

Will this database ever be used in a multi-user environment where another user might be making changes to the data while you have it in your array?

To answer your questions. The retrieving data is relatively small. Consisting of at most 12 characters of data. Retrieving around 10 to 15 rows at a time. For your other question. No the user will not be able to make change's to the incoming data.

Having multiple rows of data makes my job much easier in the long run of things to come.

Ok it would seem your design is at least a reasonable choice then.

Will you have any trouble with the 'make a copy of the data' part?

I've tried all kinds of different copying methods. But all retain the same address from the row function. No matter what I do.

Show me some code.

I want to see your database access and at least one attempt at making a copy of the data.

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.