|
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
|
|
|
|
|
it's include with win 2000 professional!
|
|
|
|
|
The question was, "How do I make it work on any Win 9x or 2000 machine?" For this,
you will always need MDAC. The newest version (with patches) is not the one that was
distributed with Win2K, but has been since updated.
CodeGuy
http://groups.yahoo.com/group/wtl
|
|
|
|
|
I want to copy a table (not rename - the original table should remain as it is) with all the data in it to another table. Is there any way to do it inside a stored procedure in MS SQL Server?
Thanks
Thomas George
modified 29-Aug-18 21:01pm.
|
|
|
|
|
Highlight the table and select All Tasks -> Export. This will bring you into DTS. Select the Source and then the Destination (in this case they will be the same). Select Copy Table(s), hit next, select the table you want from the source drop-down and then type in a name for the destination table. You can use Transform here to manipulate the fields, etc. Hit Next, you can run this imediately or save in which you can call this DTS Package from a Job, Stored Procedure, etc. (See BOL about calling DTS packages from an sp.)
Another way:
Select * into (new_table_name) from (old_table_name)
This will create a new table with all the info. (NOTE: This 'transfer' is not logged as a transaction, thus can not be rolled back. I believe you can check FULL RECOVERY on you DB and this will correct this.)
Good Luck!
|
|
|
|
|
I have recently installed both SP5 and the Processor Pack to visual C++ 6 and I am having the following
problem. When an exception occurs inside a try catch block inside a function that calls ado methods
the function crashes (in the debug build) on return. The following code runs fine when compiled with
an earlier service pack and no processor pack, but with SP5 + Processor Pack it crashes during the return
from the test function. Also if I compile it on a pc with an eariler sp, it will debug and run fine
on a machine with the latest sp (as long as you don't try to compile!).
The following code has been reduced to the smallest part that I could get it to crash. I compiled it
as a Win32 console application and did not change any of the default values. In SP5 + processor pack
an access violation occurs when test() returns. This was tested on win2k. I compiled and tested it in
debug build only.
#include "stdafx.h"
// You must change this to match your path
#import "D:\program files\common files\system\ado\msado15.dll" \
no_namespace \
rename( "EOF", "adoEOF" )
void test()
{
_RecordsetPtr pRst = NULL;
try
{
throw "a";
pRst->Open(_variant_t(), _variant_t(),adOpenStatic ,
adLockReadOnly, adCmdText);
}
catch (...)
{
}
}
int main(int argc, char* argv[])
{
test();
return 0;
}
My question is 1) Has anyone seen this problem? 2) am I doing something wrong?
|
|
|
|
|
your code where you have
throw "a";
looks well dodgy !!!!
maybe you should remove that
|
|
|
|
|
Hi all.
I'm looking to read a flat/fixed width text data file with ADO. I'm assuming that i'll have to write a Schema.ini with all the field definitions in before hand.
Is this correct?
Also, the nice Fixed with import wizard in Access, is there anyway to automate this? I.e., me use it in my app?
Thanks! Pete
|
|
|
|
|
Hi, I was wondering if there was any way I could check for the existence of a field in a table without poking the database and handling an error. I'm sure there is a way, but all my searching has led to no avail.
|
|
|
|
|
use the FieldsPtr class
e.g.
FieldsPtr ptrFields = NULL;
FieldPtr ptrField = NULL;
ptrFields = m_pRS->Fields;
int nCols = ptrFields->Count;
FieldPtr ptrField = NULL;
_variant_t vCol((long)-1);
for (int i = 0; i < nCols; i++)
{
vCol.lVal = i;
HRESULT hr = ptrFields->get_Item(vCol, &ptrField);
if(FAILED(hr))
_com_issue_error(hr);
if ((LPCSTR)ptrField->Name == "My Field")
{
}
}
|
|
|
|
|
Hi!!
I am using ASP-script and an access-database. I want to make a select query
that shows all the data in many tables how is it possible to do this?
An example:
I want to see the names of all companys in the company-table and I also want
to see their adresses wich are in the adress-table and I also want to see
their email-adresses wich are in the email-table. But I also want to see
the companys who do not have for example an email-adress. How is it possible
to extract this kind of data?
/Martin S
|
|
|
|