Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

SQL Server xp

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
UncleMatt
Asked:
UncleMatt
  • 9
  • 7
1 Solution
 
UncleMattAuthor Commented:
I forgot to mention I am writing it in Visual C++

Oops!
0
 
IainHereCommented:
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
 
IainHereCommented:
>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
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.

 
UncleMattAuthor Commented:
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
 
IainHereCommented:
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
 
UncleMattAuthor Commented:
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
 
IainHereCommented:
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
 
UncleMattAuthor Commented:
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
 
UncleMattAuthor Commented:
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
 
UncleMattAuthor Commented:
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
 
IainHereCommented:
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
 
UncleMattAuthor Commented:
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
 
IainHereCommented:
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
 
UncleMattAuthor Commented:
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
 
UncleMattAuthor Commented:
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
 
IainHereCommented:
Oh dear, hope you're better now, and thanks for the points  :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 9
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now