Solved

SQL Server xp

Posted on 2001-08-01
16
217 Views
Last Modified: 2010-04-02
I'm tring to write an xp for SQL Server 7.

When I build it in debug mode it returns one set of records and when I build it in release mode it brings back a different set of records.

I'm not a C++ programmer so I have no idea of what might be causing this problem.

Any help would be gratefully accepted.

Cheers.

Matt.
0
Comment
Question by:UncleMatt
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 2

Author Comment

by:UncleMatt
ID: 6340048
I forgot to mention I am writing it in Visual C++

Oops!
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6341199
What is the difference between the records?  Are they from the same table? database?

Are there any other obvious differences between the debug and release versions?  Does the software work fine apart from this?

Which set of records (if either) is the correct one?  ie which set were you expecting to see?
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6341252
>I'm not a C++ programmer so I have no idea of what might be causing this problem.

What kind of advice are you expecting?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:UncleMatt
ID: 6341685
Iain,

I'm returning 1 row to SQL Server, when in Debug it returns correctly, when in Release it doesn't only returns 2 of the fields and null in the others.

I was stupidly hoping for it to be an obvious setting problem or something, give me a break, I haven't touched C in 2 years and never to this depth.

Matt.
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6343869
Are you writing the data to the database or reading from the database when the problem occurs?  Is it repeatable, or does it work the first time and fail subsequently? If reading from, are you sure that you're not simply reading a different row (I know, a stupid mistake, but I've made stupider in the past).

How many fields are there, and of what type are they - for instance, can you read[/write] int but fail to read string?  If you know where the problem is occurring in the code, could you post a few lines - I think it's unlikely to be a setting problem.

Apologies for above comment, and break given.
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6344131
In the xp I'm accessing data from an API call to a 3rd party DLL and sending it to the SQL Server as a row of 6 strings.  

It's a postcode lookup system.  

In debug mode it returns all the rows correctly, but in release mode, with the same arguments it only returns 2 of the 6 fields correctly.  

I'm in contact with the company that supplied the postcode DLL aswell to see if they can help, but I'm confused by the different results for different versions.

Matt.

PS Apology accepted, and thanks for the break, first one this week!!
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6344185
Do you have debug and release versions of the DLL, or are you using a release version for both versions of your XP?

The first thing I would do would be to write the strings to a file (or a messagebox) just before you return them to the database.  At least then you'll know roughly where the problem is.  I've done lots of database work, but never actually written an XP - if its something specific to how they work, then it'll be beyond me.  From how it sounds, I would *guess* that it's to do with initializing the variables though, which is done for you in the debug mode, but if you haven't looked after your memory properly, this is the kind of thing you could hit.  Could you post some code?

Oh, and maybe a link to this in the MSSQL TA would bring someone with more knowledge of XP.
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6345422
I don't think it's the xp specific code because the strings are empty anyway.  I'll check out the variable initialisation in the morning and if I don't have any luck I'll post my code.

Matt.
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6348025
I think I've found my problem.  The postcode lookup uses a structure of char arrays and when it is returned with the information, they aren't null terminated.  Some of the fields are getting lost in my moving them from the struct to the output.

I've definately proven that its not the xp specific stuff then, but I've got to think of a way to get the information out I need.

Any suggestions would be great, as I mentioned before C++ is not my area.

Matt.
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6348154
Right, I think I've fixed it.  

I accessed to structure in the order of it's definition and it almost worked, I needed to do something with one of the variables first, before sending it back to SQL Server before SQL Server could see it, so I just put it in the column twice (That sounds like a typical VB problem).  

It works now.

Thanks for the help Iain, I'll give you the points when I get home (work internet access is not so good.)
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6349301
I've just thought - are you Uncle Travelling Matt :-)

I don't really understand what your last comment means, about putting it in the column twice, but it sounds like it might be a hack?  Then again, since you say it sounds like a typical VB problem, you probably know what you're doing.  C-style strings (char arrays) cause so many problems; Are you fully happy with your solution, or would you like a hand?
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6349328
I've just written another xp this afternoon and I had no problems at all after I accessed the data in the defined order, so I'm going to have a look at the original one tomorrow (Yes I have to get up on Saturday morning (again)) and see if I can fix that one without the hack I used (yes VB does need some bodging every now and then).

The string handling is coming back to me after 2 years of not touching C, but any advice on strings and structs of strings would be useful.

Why the question about Uncle Travelling Matt, you sound as if you think you know who I am?  I used to be nick-named UTM but the travelling got dropped when I stopped driving for a living!

Matt.
0
 
LVL 4

Accepted Solution

by:
IainHere earned 150 total points
ID: 6355029
I just remember watching Fraggle Rock as a kid, and all those postcards from UTM.  

Anyway, unless you fixed your problem over the weekend: if you're passing a struct in to the dll and some of the members are char*, then it would be very bad practice on the part of the library provider not to return the length of the string as well as the string itself (and doubly so if it's not bothering to terminate the string) - could you post the struct, and the signature of the function?  Perhaps also the code you're using to read from dll and write to DB - if there's not too much of it.
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6356295
Our work internet has been down all day so I can't post any code but the 2 I have written since the one I have had the problem with have worked without any trouble, I haven't had a chance to play with the original one again yet as it's been a little hectic today.

I'll try and post some code tomorrow.

Matt.
0
 
LVL 2

Author Comment

by:UncleMatt
ID: 6803668
sorry, have been in hospital for a number of months, trying to catch up now.

Thanks for your help all that time ago.

Matt.
0
 
LVL 4

Expert Comment

by:IainHere
ID: 6807165
Oh dear, hope you're better now, and thanks for the points  :-)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Would like to move button in a function 3 92
c++ substatte a varabe for a string in a LPCTSTR statment 8 100
What is sub-make ? 2 102
Adding items to a C# list incrementally 5 82
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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