|
error C2487: 'CSingleton<T>::ms_pSingleton' : member of dll interface class may not be declared with dll interface
When I try to compile the below code in VS2008 above is the error. I am not sure hw to fix this, as the class is not exported (i am getting this error even when i try to export the member alone).
So please suggest me a better solution.
template <typename T>
class CSingleton
{
private:
ExportSlotCoreLib static T* ms_pSingleton;
CSingleton(const CSingleton&);
protected:
CSingleton() {
//assert(ms_pSingleton == NULL);
int offset = (char*)(T*)1 - (char*)(CSingleton <T>*)(T*)1;
ms_pSingleton = reinterpret_cast<T*>(reinterpret_cast<char*>(this) + offset);
}
~CSingleton() {
//assert(ms_pSingleton != NULL);
ms_pSingleton = NULL;
}
public:
static T& GetSingleton() {
return (T&)*ms_pSingleton;
}
static T* GetSingletonPtr() {
return ms_pSingleton;
}
};
Thanks,
Nandu
|
|
|
|
|
Can you remove ExportSlotCoreLib from pSingleton declaration and try?
|
|
|
|
|
Hi All
USE database command is not working for me.I was asking same question in last week but still i have no solution then i ask one more time.Plz help me
connection code is here
CString str1="",str2="",str3="";
HRESULT hr;
if SUCCEEDED(hr = CoInitialize(NULL))
{
try
{
if (SUCCEEDED(spSQLServer.CreateInstance(__uuidof(SQLServer2))))
{
try
{
HOST=(_bstr_t)m_MHOST;
if(rad1.GetCheck())
{
spSQLServer->LoginSecure = TRUE;
spSQLServer->Connect((_bstr_t)m_MHOST);
}
else
{
spSQLServer->LoginSecure = FALSE;
spSQLServer->Connect((_bstr_t)m_MHOST,(_bstr_t)m_MUSR,(_bstr_t)m_MPWD);
}
}
catch(_com_error pCE)
{
str2.Format(_T("%s"),
MessageBox(str2,"Message");
return TRUE;
}
}
else
{
str3.Format(_T("Unable to create the SQL Server object.\n"));
}
}
catch(_com_error pCE)
{
str2.Format(_T("\n%s Error: %ld\r\n%s\r\n%s\r\n"),
(TCHAR*)pCE.Source(),
pCE.Error(),
(TCHAR*)pCE.Description(),
(TCHAR*)pCE.ErrorMessage());
}
}
else
{
str2.Format(_T("Call to CoInitialize failed.\n"));
}
Use database command code is here
QueryResultsPtr Qry;
_SQLServer2Ptr spSQLServer;
CString udata="use 'databasename'";
Qry=spSQLServer->ExecuteWithResults((_bstr_t)udata,(LONG)udata.GetLength());
Select command is running fine like this
CString sel="select * from 'Database name'.dbo.'Table Name'"
Qry=spSQLServer->ExecuteWithResults((_bstr_t)sel,(LONG)sel.GetLength());
Can any one help me why
USE 'Database name' not working.
Plz help me
|
|
|
|
|
MsmVc wrote: USE database command is not working for me.
-explain, does it give an error, does it simply not do what is expected (e.g: it completes successfully but does not seem to make any change), how do you know it fails?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
it completes successfully but does not seem to make any change.
After use database command then i check through this command.
SELECT DB_NAME() AS DataBaseName
it's always show "Master" database name.
|
|
|
|
|
Let's experiment, try this:
CString udata="use \"databasename\"";
Qry=spSQLServer->ExecuteWithResults((_bstr_t)udata,(LONG)udata.GetLength());
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
thanks ,i use code which is given by you.But i got error
Microsoft SQL-DMO (ODBC SQLState: 42000) Error: -2147221402 [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'databasename'. Invalid STDGMEDIUM structure
|
|
|
|
|
How about CString udata="use databasename"; ? Btw do you know that -according to msdn- Microsoft recommends not using sql-dmo in newer products because it will be removed by them?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
thanks for information.
So what i use?Plz help me
|
|
|
|
|
This[^] is where i found that you should avoid using it, just to show you i didn't make that up. Otherwise, i don't know what else there is, i guess you should ask Microsoft (look around MSDN), or you could try using Oracle Database 10g client[^], i think it is an ODBC "interface" of somesort...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Your database's name is
Database name ?
in such a case, possibly you've to replace
MsmVc wrote: CString udata="use 'databasename'";
with
CString udata="use 'Database name'";
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i always use like this
CString udata="use 'Database name'";
But still i have problem same.
|
|
|
|
|
uhm,
I think: the USE keyword (in t-sql) follow by YourDBName (YourDBName without quote) like this
USE YourBDName
or
USE [YourBDName]
|
|
|
|
|
Thank
But i test both case there is no effect in out put.Still same problem here.
|
|
|
|
|
Did you put USE YourDBName query and select query in same connection session ?
WHEN and WHERE did you use SELECT DB_NAME() AS DataBaseName ?
|
|
|
|
|
See as in first post first i make connection then i use
CString tr="USE tes";
Qry1=spSQLServer->ExecuteWithResults((_bstr_t)tr);
this code.
After that i use
SELECT DB_NAME() AS DataBaseName
If i am wrong then pls help me
|
|
|
|
|
|
hi,
i want to know that,how to delete a particuler file using a path in vc++
i knew that DeleteFile() ,resolve it...but i have a piece of code ..will show below..can u give me the solution ..
i stored the path in Dir,
Dir = "d:\testapp\abc.exe"
now delete a file:
deletefile(Dir);//if i take path like this then this function will delete it. //("d:\\testapp\\abc.exe")
now i want to delete this file using single slash("\") inside path..
anybody know???
|
|
|
|
|
|
Hi kamalilam,
kamalilam wrote: now i want to delete this file using single slash("\") inside path..
As per C++ Character Constants[^], \ has special meaning in strings.
So - "d:\\testapp\\abc.exe" is really "d:\testapp\abc.exe".
Best Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Is there a application that can export Line Drawings, into POINT = {4,5,10,12...} struct arrays.. to be used with API calls like Polyline(...)
|
|
|
|
|
You may use, for instance, a Windows Metafile [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well i was thinking of more of a drawing tool, or somewhat that could convert it into POINT locations instead? so you could use Polyline, to draw out the item.. Microsoft example uses
POINT aptHexagon[7] = {50,2, 93,25, 93,75, 50,98, 7,75, 7,25, 50,2};
but the Hexagon is way too big, editing it manualy takes alot of time to make it smaller because you would have to recompile to see if lines match up
|
|
|
|
|
I'm hosting Windows Media Player in an application and can't figure out how to detect when a clip is done playing. Unfortunately, the EndOfStream event isn't implemented. I ran across the idea to use the MediaChange event, but I can't see how that's helpful since it's called multiple times and not very accurately.
Does anyone have a working solution?
|
|
|
|
|
To answer my own question, it appears that PlayStateChange event passes a value of 8 when the media is done.
|
|
|
|