DirectX with MSSQL

Started by
5 comments, last by Mykre 18 years ago
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?
If you don`t do something, something will do, something to you!
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?
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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?
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.
If you don`t do something, something will do, something to you!
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.

Niko Suni

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.
ZMan

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.
Mykre - BlogVirtual Realm :- XNA News and Resources from Down Under** For those Interested in an Australian XNA User Group Contact me though my site.

This topic is closed to new replies.

Advertisement