|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
I was looking for an efficient way to store "States" of entities in the DB. For example I had OrderStatus and that can be mapped to a table called Status and have the ID and the status Name be present in a join. If however I wanted to add more statuses for other Entity tables I don't want to have to create a new table for every Entity, is there a way to store all these statuses in one table? Thanks
|
|
|
|
|
|
Richard Deeming wrote: It's a bad idea.
I , the last project I was asked to advise on was managed by a PM who was adamant that this was the "modern" way to go (I was accused of being an old fart who was stuck in the 90's). Started off as a 2 column table and the last I saw of it was a 5 column, 2 table structure.
Luckily I walked away from anything to do with the project.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I take this point, I restructured my schema to just have 1 table per type for the time being, I was just trying to have less tables and then ran into this anti-pattern. Thanks for the input.
|
|
|
|
|
I need help resetting the values of each users in a row at once with random numbers by either button click or loading a page.
Just like a reset page or button to assign random numbers to each users without repeating at once.
|
|
|
|
|
You most likely need to use a set of UPDATE statements in order to use different random values.
|
|
|
|
|
I need a real-time database for inserting at least 500fields per second. (I have been selected TimeScaleDB (Postgresql Extension) for my purpose, currently). So, the matrix of the table will be 500(Fields)x86400(Rows).
This means that for a 500 double-precision field it will be around 500*8bytes=4000bytes which for 86400rows it will be 345,600,000bytes (345.6M).
I know a software which it is recording the same structure of data and the final daily volume of its database is only 84M~85M. Its Extension is *.tag so, i think it is a DataFlex database. It is not a free database and i also never used it.
Question:
1- Which free database is the best to use for real-time data storing and querying (at the moment of storing) based on your experience or knowledge?
2- Is there any database to have such a volume or even less for this size of data?
Thank you for your Help.
|
|
|
|
|
|
But Its Volume Will Be The Same As PostgreSQL!
|
|
|
|
|
Why are you concerned about sizes? Disk space is cheap.
|
|
|
|
|
For one year the size will be 120GB for Postgresql but for the mentioned DBS will be only 30GB. it is a great difference (one fourth).
|
|
|
|
|
That would mean the other database is storing the data compressed.
That's obviously something you can do in many databases, but it might add performance issues.
Wrong is evil and must be defeated. - Jeff Ello
Never stop dreaming - Freddie Kruger
|
|
|
|
|
|
What is wrong with MySQL[^]
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
|
There are various ways to "compress" (and structure) redundant database data. "Size" doesn't tell much of a story.
And you don't generally "query" real-time data; plot it, maybe; record it, certainly; usually to a binary file that later gets translated and loaded (to a database) for information purposes.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi,
when writing in Access database using ADO and record binding, I run into an exception after some time.
I wrote a small console program to demonstrate the problem :
#include <Windows.h>
#include <iostream>
#import "c:\Program Files\Common Files\System\ADO\msado15.dll" no_namespace rename("EOF", "EndOfFile")
#include "icrsint.h"
_COM_SMARTPTR_TYPEDEF(IADORecordBinding, __uuidof(IADORecordBinding));
void OpenDatabase();
void WriteToDatabase(int i);
void CloseDatabase();
_ConnectionPtr m_pConnectionPtr = 0;
DWORD64 cnt_recordset;
int main()
{
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
m_pConnectionPtr = NULL;
m_pConnectionPtr.CreateInstance(__uuidof(Connection));
int cnt = 0;
cnt_recordset = 0;
OpenDatabase();
while (1)
{
std::cout << cnt++ << " : " << cnt_recordset << std::endl;
for (int i = 0; i < 1000; i++)
WriteToDatabase(i);
}
CloseDatabase();
CoUninitialize();
}
void OpenDatabase()
{
bstr_t strCnn("Provider=MSDASQL;DSN=TestDB;User ID=sa;");
m_pConnectionPtr->Open(strCnn, "", "", NULL);
}
void CloseDatabase()
{
if ((m_pConnectionPtr->State == adStateOpen))
m_pConnectionPtr->Close();
}
void WriteToDatabase(int i)
{
cnt_recordset++;
class CMyRecordSet : public CADORecordBinding
{
BEGIN_ADO_BINDING(CMyRecordSet)
ADO_VARIABLE_LENGTH_ENTRY2(1, adInteger, m_nID, sizeof(m_nID), m_IDStatus, FALSE)
ADO_FIXED_LENGTH_ENTRY(2, adInteger, m_value, m_valueStatus, TRUE)
END_ADO_BINDING()
public:
int m_nID;
int m_value;
ULONG m_IDStatus;
ULONG m_valueStatus;
};
HRESULT hr = true;
_RecordsetPtr pRs("ADODB.Recordset");
CMyRecordSet rs;
IADORecordBindingPtr picRs(pRs);
hr = pRs->Open("TTagData",
_variant_t((IDispatch*)m_pConnectionPtr, true),
adOpenKeyset, adLockOptimistic, adCmdTable);
hr = picRs->BindToRecordset(&rs);
rs.m_value = i;
picRs->AddNew(&rs);
pRs->Close();
}
The exception occurs on closing the recordset after the AddNew :
inline HRESULT Recordset15::Close ( ) {
HRESULT _hr = raw_Close();
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
return _hr;
}
Exception number is 0x800a0c93
This happens after a couple of hundreds of thousends writes.
Am I missing something?
Any help is appreciated very much!
|
|
|
|
|
From ErrorValueEnum - SQL Server | Microsoft Docs[^]
adErrIllegalOperation 3219 -2146825069 0x800A0C93 Operation is not allowed in this context.
Which, like so many error codes, does not tell you much. You could try one of the Microsoft forums.
|
|
|
|
|
Quote: This happens after a couple of hundreds of thousends writes. Access is probably not the best database of choice for that many records to be honest.
How big (size on disk) is your .accdb file? There is an absolute maximum size for an Access database of 2GB - you may need to consider linked tables to bring the size down
|
|
|
|
|
Database is only 126MB big at that stage so this could not be the cause.
I have rewritten the code without datarecord binding :
void WriteToDatabase2(int i)
{
_RecordsetPtr pRs("ADODB.Recordset");
HRESULT hr;
char sql[128];
sprintf(sql, "insert into TTagData([Value]) values (%d);", i);
hr=pRs->Open(_variant_t(sql),
_variant_t((IDispatch*)m_pConnectionPtr, true),
adOpenStatic, adLockReadOnly, adCmdUnknown);
}
Have written a couple of million of records and now I don't get the exception!
Is there something wrong with the datarecord binding or the way I use it??
|
|
|
|
|
I have rewritten the code without datarecord binding :
void WriteToDatabase2(int i)
{
_RecordsetPtr pRs("ADODB.Recordset");
HRESULT hr;
char sql[128];
sprintf(sql, "insert into TTagData([Value]) values (%d);", i);
hr=pRs->Open(_variant_t(sql),
_variant_t((IDispatch*)m_pConnectionPtr, true),
adOpenStatic, adLockReadOnly, adCmdUnknown);
} Have now written a couple of million of records and now I don't get the exception!
Is there something wrong with the datarecord binding or the way I use it??
|
|
|
|
|
According to Open Method (ADO Recordset) - SQL Server | Microsoft Docs:
It is not a good idea to use the Source argument of the Open method to perform an action query that does not return records because there is no easy way to determine whether the call succeeded. The Recordset returned by such a query will be closed. To perform a query that does not return records, such as a SQL INSERT statement, call the Execute method of a Command object or the Execute method of a Connection object instead.
|
|
|
|
|
OK, so I changed my code to something like this :
_CommandPtr pCmd;
pCmd.CreateInstance(__uuidof(Command));
pCmd->ActiveConnection = pConn;
pCmd->CommandText = "Insert into [table] ([value]) values (1)";
pCmd->Execute();
Now in the table is an autoincrement ID which I need for use in a linked table.
Does the pCmd->Execute() return a recordset and if so what's in it?
Or is there another way to get the data of the just added record?
I find very few information on this topic.
|
|
|
|