[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What data type to use?

Posted on 2006-05-07
15
Medium Priority
?
183 Views
Last Modified: 2013-11-20
Hi.
I`m trying to think for a nice way to handle my problem, but have come up with nothing.
I have a table of web pages users have viewed. This table has two colomns UsrID and PageURL. I want to select UsrID and PageURL of all users that answer a certain criteria. Up till here everything is easy.
My problem is that I need to pass this data to unmanaged c++ code and I can`t think of a data type that will do this nicly.
The only thing I have been able to come up with is creating an array of strings, with each string holding a comma seperated list of all visited web pages for a single user.
This is a very ugly way to do it, but I can`t think of anything nicer.
Hope maybe someone here can help.
Thank you in advance for any help you can supply.
Elad.
0
Comment
Question by:Eladla
15 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 16625540
Actually a comma-separated list is not really a good idea, since commas are valid characters in URLs also. Depending on the way you want to call the unmanaged code, I'd suggest to go for VARIANTs that hold BSTRs with COM interop. You could either pass an array of VARIANTs or VARIANTs that contain SAFEARRAYs of BSTRs.
0
 
LVL 6

Author Comment

by:Eladla
ID: 16625577
Thanks for the comment.
First of all I have no commas in my urls, so that isn`t going to be a problem.
What you are suggesting is an array of arrays?
Could I pass that from VB to c++ or is that going to be trouble?
I want to use the least amount of platform specific code that I can and I guess working with variant and safearray will not help me in that respect.
Any other ideas?
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16625898
One way that windows handles this type of problem (I think) is to have a string (char x[2048] for example) and use the value 0 to separate individual values and  a 00 to indicate the end of the string.
Could that be suitable for you?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 14

Expert Comment

by:puranik_p
ID: 16628287
tou can use this format:

[user1]URL1~URL2|[user2]URL1~URL2~URL5|[User3]URL7~URL1
 
0
 
LVL 6

Author Comment

by:Eladla
ID: 16631048
Nice ideas...but I`m looking for something more creative if possible.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16631110
I could give you some very creative ideas if you really wanted.  Personally I prefer the simplest that works efficiently (easy to code, easy to maintain, easy for others to understand).  Is there anything about my suggestion which rules it out?
0
 
LVL 6

Author Comment

by:Eladla
ID: 16631181
Well.....to all intents and purposes your idea is just a more complex version of my idea.
Since I decided my idea will be a last resort...I`m trying to find maybe a nicer way than an array of string each holding a comma seperated list (or anything similar to that)
So to answer your question, I really want something more creative.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16631244
I don't mention array at all.  I talk about ONE string variable and only one string variable to store everything in it.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16631252
AFAIK a zero wouldn't be a valid character so that is used as a separator between the fields. Two zeros next to one another determine the total length of the string buffer in use for the recipient.
0
 
LVL 6

Author Comment

by:Eladla
ID: 16631422
I see.....well....what I need to store in this data type is a list of all visited pages grouped by the visiting user.
I don`t see how your idea does this, please alaberate.
Thanks.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16631634
I have just reread your question in light of your last comment.  I had misunderstood, I thought the list you wanted was one user, one page, next user, next page...

OK forget the suggestion then.
0
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 750 total points
ID: 16631797
Actually just requires a minor extension.
Use a single zero to separate items, a double zero to inicate another user and a triple zero for the termination.
eg.
User Andy visits www.ainscow.ch
User Benny visits www.xyz.com and www.someothersite.com

string is
Andy0www.ainscow.ch00Benny0www.xyz.com0www.someothersite.com000

the 0 are actually a zero NOT the character '0'
0
 
LVL 6

Author Comment

by:Eladla
ID: 16632732
Sounds good....
I`ll try it out and see if it isn`t too inefficient.
I would be more comfortable with an integer array based solution...if thats possible
in this scenario.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 16636835
By integer array based do you mean
int x[2048] instead of char x[2048]
for the packed information?

if yes then it is basically just the same.



efficiency - memory usage should be better than a collection of arrays, to unpack you just increment a pointer to pick off where the next string begins (don't forget that zero is used as the normal termination character for a string).  To pack it is similar.
0
 
LVL 6

Author Comment

by:Eladla
ID: 16637991
ok....I`ll take that.
Thanks!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question