|
... trying to get a FOR XML rowset back out through ADO/ASP now, and its becoming a nightmare!
strings I select like this: SELECT '<hello/<' are just great, but something simple like:
SELECT blah
FROM blogg
FOR XML AUTO, ELEMENTS
gives me rubbish, like:
?colname??L?anothercol?a??somethingelse?andmoreshite
which isn't making much sense to me, unless its a UNICODE problem...
thanks in advance if anyone can help
Nick
|
|
|
|
|
I have an ASP page in which I am trying to start a transaction
<br />
var Conn = Server.CreateObject("ADODB.Connection");<br />
Conn.Open("MyDB");<br />
Conn.BeginTrans();<br />
Conn.Execute("sp_InsertNew " + name);<br />
The stored proc, sp_InsertNew, as you would imagine just inserts a record into a table
When I try this I get the error, "Transaction cannot start while in firehose mode."
MSDN says this is a bug with SQL Server 2000 and the Enterprise Manager. The problem is I am trying this with an ASP page and ADO connection.
Can anyone shed some light on this?
|
|
|
|
|
Im using ADO to access an SQL server and everything is working ok except
for when an error occurs.
Then the description and source properites in the error object is
*always* null.
The native error number is how it should be.
Anyone got a clue what could cause this?
(we also access the db with MFC and ODBC and there the description is correct)
/Magnus
|
|
|
|
|
Send your code snippet so we can have a look at what you are doing wrong
|
|
|
|
|
Here is the codesnippet used to get the error.
The _ConnectionPtr passed in is either the connection
pointer used to execute the command or gotten from
_RecordsetPtr->GetActiveConnection()
NativeError contains a valid number as said but all strings are NULL.
void EmitError(_ConnectionPtr piCon)
{
if(piCon == NULL)
return;
ErrorsPtr ptrErrors = piCon->Errors;
if(ptrErrors == NULL)
return;
long lCount = ptrErrors->Count;
ErrorPtr ptrError = NULL;
CString sError;
for(long n = 0; n < lCount; n++)
{
ptrError = ptrErrors->GetItem(n);
if(!(ptrError == NULL))
{
LogEmit("%s\nState: %s, Native: %d, Source: %s\n\n",
(LPCTSTR)_bstr_t(ptrError->GetDescription()),
(LPCTSTR)_bstr_t(ptrError->GetSQLState()),
ptrError->NativeError,
(LPCTSTR)_bstr_t(ptrError->GetSource())
);
}
}
}
/Magnus
|
|
|
|
|
use exception handling e.g.
try
{
HRESULT hr = piCon->....;
if (FAILED(hr))
_com_issue_error(hr);
}
catch(_com_error& e)
{
CString sBuff = GetErrorDescription(e);
AfxMessageBox(sBuff);
return;
}
catch(...)
{
AfxMessageBox("Unknown Error Occured");
return;
}
CString GetErrorDescription(_com_error& e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
_TCHAR szTemp[1024];
CString strInfo ;
wsprintf(szTemp, _T("Message : %s\n"), e.ErrorMessage());
strInfo = szTemp;
wsprintf(szTemp, _T("Code : 0x%08lx\n"), e.Error());
strInfo += szTemp;
wsprintf(szTemp, _T("Source : %s\n"), bstrSource.length() ? (LPCTSTR)bstrSource : _T("null"));
strInfo += szTemp;
wsprintf(szTemp, _T("Description : %s\n"), bstrDescription.length() ? (LPCTSTR)bstrDescription : _T("null"));
strInfo += szTemp;
return strInfo;
}
|
|
|
|
|
I do use exception handling, thats from where a try to get the ado-errors.
The problem is not catching the error but that the description field is NULL.
I can get the HRESULT, native error,.. but that are not very friendly messages.
I dont think the code that tries to dig out the error is to blame here, the problem must lie somewhere else,.......and i dont have a clue where.
/Magnus
|
|
|
|
|
Hi all,
I'm trying to use IXMLHTTPRequest to send an XML document (from a C++ client app) to a template on a SQL Server. It appears IIS support is configured properly, because putting the document directly in the url works - like this:
http://myserver/virtualdir/templates/mytemplate.xml?doc='<root/>'
The template is:
<ROOT xmlns:sql='urn:schemas-microsoft-com:xml-sql'>
<sql:header>
<sql:param name='doc'>'default'</sql:param>
<sql:header>
<sql:query>
exec usp_MySP @doc
</sql:query>
<ROOT>
In code, I open an IXMLDOMDocument, and load xml into it. Then, I open an IXMLHTTPRequest and send the document:
hr = pIXMLHttpRequest->open(_bstr_t(_T("POST")),
_bstr_t(_T("http://myserver/virtualdir/templates/mytemplate.xml")),
_variant_t(VARIANT_FALSE),
_variant_t(""), _variant_t(""));
hr = pIXMLHttpRequest->setRequestHeader(_bstr_t(_T("Content-type")),
_bstr_t(_T("application/xml")));
hr = pIXMLHttpRequest->send((IDispatch *)pDoc);
The stored procedure always gets the default parameter, not whatever document I pass in.
Thanks for any help with this cryptic stuff
Cheers
NB
|
|
|
|
|
How can I check if MDAC is installed on the machine in Visual C++ ?
|
|
|
|
|
There's a registry key HKEY_CLASSES_ROOT\MDACVer.Version with a subkey CurVer with the value like MDACVer.Version.2.60.
I don't know if all MDAC version supports this key.
Volker
|
|
|
|
|
use this code on ::InitInstance
CLSID clsid;
HRESULT hr = AfxGetClassIDFromString("Datalinks", &clsid);
if(!SUCCEEDED(hr))
{
AfxMessageBox("You need to install MDAC v2.1 or higher");
return FALSE;
}
|
|
|
|
|
Hi there Guys! Hope someone out there can help!
I have a multi-threaded application that uses OLE DB and the MS Jet engine to call into a shared Access database. I have a critical section which get's locked and unlocked before and after accessing the DB, therefore stopping any other thread from accessing it whilst it is being used by another thread.
However, I am getting some errors. I initially thought it may be the critical sections, and so changed them to mutexes, but have since proved that this isn't the problem. The problem I am getting is this:
[Microsoft][ODBC Microsoft Access Driver] Could not update; currently locked by user 'me' on machine 'xxxxxx'
So silly me! I'm trying to access the database when it is apparently still locked - even though the first thread has stopped accessing it! There seems to be some latency involved in the first thread letting go of the database properly and the next one calling in.
I have thought on checking for existence of the ".ldb" lock file, but this just seems crap! Surely there is a more elegant way!? Any help/ideas would be greatly appreciated!
|
|
|
|
|
This may not be related - but
Do you call CoInitialize(NULL) and CoUnitialize() in all your Threads? This basically loads the OLE Library that OLE DB requires.
|
|
|
|
|
Perhaps calling the IIdle::Idle would remove the locks? The Jet OLE DB docs makes it clear that we should call this methods frequently.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hi
Im using the Refresh Method With ADO C++(I had to many problems with Createparameter Method)
bstr_t bstr = L"DSN=MEAS2SQL;
pCon->Open(bstr, (BSTR)NULL, (BSTR)NULL, -1);
pCommand->ActiveConnection = pCon ;
pCommand->CommandType = ADODB::adCmdStoredProc
pCommand->CommandText = _bstr_t("URBAN");
"It works with executing a stored procedure without parameters"
But when i inlude parameters with this lines i get the error.
pCommand->Parameters->Refresh();
pCommand->Parameters("@pkMbtID") = '160';
I get the error:
error C2064: term does not evaluate to a function
I spent several hours with this Plezz Help.
PS. They say CreateParametr is Faster then Refresh Method i wonder how much faster?
|
|
|
|
|
Parameters is a collection, so you have to use.
In VB the Item property is the default property of the parameters collection.
But in C++ there are no default properties.
BTW I don't thing defaulting everthing as done in VB does the programmer
do an favour. Defaulting rules can change, because there are defined
by the type lib you are coding againts.
So if you happen to have a newer type lib installed where the default props have changed, you
will run into trouble. So I have the attitude to never depend on default probs
and methods in any language I use (VB, C++, VB script)
pCommand->Parameters->Item[_T("@pkMbtID")]->Value = _T'160'
And is your parameter really a string or is it a number ?
The Value is a _variant_t, so you can stuff in a number, if that's what you really want.
|
|
|
|
|
Hi there,
I was wondering why you would want to use an identity column as opposed to using a Primary Key or UniqueIdentifier data? What's the advatnage if any?
Where would this be suitable?
|
|
|
|
|
The Identity column generates a unique identifier for you, therefore you do not need to worry about generating a unique identifier?
This is suitable when you require a unique identifier !!!
|
|
|
|
|
I'm deployng an application ith Visual c++ 6.0 + service pack 6 on a PC where i have installed win2k.My problem is that qhen i try to connect to a MSACCESS database (either 97 or 2000) usign ODBC technology in the output window appears this message (i think it's a TRACE message) "First-chance exception in SimoFatt.exe (KERNEL32.DLL): 0xC0000005: Access Violation."; so my application continues its work (i do not receive any exceptions) but very very slowly. CAN SOMEONE SUGGESTS ME A SOLUTION FOR THIS PROBLEM that makes me fool?
THANKS
PS I apologize for my bad english.
|
|
|
|
|
My question relates to whether its better to maintain a connection to the SQL database and pass the the pointer to CRecordset when required or use a connectionless set-up (which seems to be the default) where you open the database during each CRecordset use?
Doesn't maintaining the connection reduce overhead? Is there any documentation on the pros and cons?
Rodney
|
|
|
|
|
Hi, I try to connect via ASP to access database, the connection seems to be ok but every time i try to write via ASP on my access database, i got a message error who said database are read only, i cant update them why?
Is it just a setting?
everythings is in a virtual directory, the connection as I said is ok but i cant write on the database...
Thanks in advance
Regard
Manon
|
|
|
|
|
Often it's because the anonymous webuser don't have write access to the directory where the access-db is...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Dear Manon
Be sure that you have a Key in your Data Base.
Drawil
Best Regards
|
|
|
|
|
I wrote a program that performs SQL operations on a access 2000 (*.mdb) database. It works fine on my machine with Access 2000 and VC++ SP3 installed. When I move it to another machine without either of these applications, my queries don't work.
I'm pretty sure that I need to update the ODBC drivers on my "plain" machine. If I was to make a re-distibutable, what files would I want to include with it so that my program will work on any Win 9x/2k platform?
Thanks,
Ryan
|
|
|
|
|
You need the latest version of MDAC + the Jet4.0SP3 patch.
http://www.microsoft.com/data
CodeGuy
http://groups.yahoo.com/group/wtl
|
|
|
|