Jump to content
  • Advertisement
Sign in to follow this  
visla

DirectX with MSSQL

This topic is 4581 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Please help me on this... I have problem. In my game I am using MSSQL. And when reading table data before CreateDevice on Direct3d object everything is ok. But when I read data after creating device correct reading is impossible. I am using pure C++ and think that problem is somewhere in using COM objects (DirectX and ADO). Is there any way to read my tables while using Direct3d9 device?

Share this post


Link to post
Share on other sites
Advertisement
While I don't have any specific insight into your problem, I think it would help if you described in more specific terms how it "doesn't work". Do database calls return an error code (if so, what error code?)? Is the data garbled? Are there exceptions?

Share this post


Link to post
Share on other sites
There shouldn't be any problem with this. COM objects shouldn't be able to interfere with each other, after all they're COM objects (Component Module Interface) - I.e. completely modular.

Does the problem happen if you create a windowed or a fullscreen device? Have you tried doing the absolute minimal setup for the device (Just create a D3D interface and then the device, using paramters you know work, and in windowed mode), and seeing if the problem persists?

Do you get any errors or warnings reported by D3D? Are you using the debug runtimes?

Share this post


Link to post
Share on other sites
Ok. Let me describe problem in more details.

First I made engine that has some kind of database reader class. And among other things engine has render device object.

When I tried to read, insert, or connect to database in small console application using this engine (dll). everything was ok.
But when I applied this readinh, inserting, connection to already finished game it had trouble reading data. As I know there is no error when connecting, reading or inserting data. When using insert or update queries data is written ok. But when using select (and gettings recordset) something gets messed up.
I tried to read date and time column from table and when I do that I dont get actual date times from table.
And debuging this application I concluded that when reading table occuring just before creating d3d9 device object data is ok. but immediately after creating device data is not correct. Doesnt have sense at all.

And yes, I am using debug runtimes for DirectX.

Share this post


Link to post
Share on other sites
Might have something to do with D3D changing the system's floating-point precision. Try to create the device with the D3DCREATE_FPU_PRESERVE flag to see if this is the case.

Mind you, I don't have intimate knowledge of SQL Server innards although I do know D3D very well.

Share this post


Link to post
Share on other sites
SQL Server stores date/time using a fixed format http://msdn2.microsoft.com/en-us/library/ms187819(SQL.90).aspx and .Net uses a fixed format too http://msdn2.microsoft.com/en-us/library/system.datetime(VS.80).aspx but I know other applications (Excel?) store their date/times in some kind of floating point storage. I can't tell how the SQLDateTime stores its value http://msdn2.microsoft.com/en-us/library/system.data.sqltypes.sqldatetime(VS.80).aspx - maybe its floating point.

This would mean that Niko's suggestion may work for you. You might also look at what types you are storing your date/times in or how your ar manipulating them at all. If at any point they go via some kind of floating point representation then you will lose accurcay for the reasons previously mentioned.

Share this post


Link to post
Share on other sites

One thing that you might want to try is to let the Database server control the date functions. Are you using Stored Procedures and Server functions if not give them a try. What you might have to do is to convert the date output from the Stored Procedures to pass the data back to your client as a varchar.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!