Help ! ... Database or object is read-only !

Hi !

I have a program which uses DAO to connect to a database.
In this database I have two different tables from where I read/write data.

Now to the problem. When I used only one table in my database I had no problems writing to the database, but now after adding the other table I can't write to it anymore(reading is possible).
When I do 'm_pSet->Edit()' I get the error message "Can't update. Database or object is read-only".
Maybe I'm the one who's slow here but I can't see any changes between my old 'one-table' set-file and my new 'two-table' set-file that would make it 'read-only'

Help appriciated.
thanx.
cbjorkmanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

inprasCommented:
Hi
When U open two tables in a sigle recordset class U have to perform join so that when U open UR recordset will know what to Open means depending on what constraint see the article below

http://msdn.microsoft.com/library/devprods/vs6/visualc/vccore/_core_recordset.3a_.performing_a_join_.28.odbc.29.htm#_core_performing_the_join

if U do what ever said I U won't get the error

Hope this helps
inpras
0
cbjorkmanAuthor Commented:
As far as I know they should be joined  since I'm able to get data from both tables. To get the data I use the following:

var = m_pSet->m_ReceptNrW;      
str = var.bstrVal;            
m_Nr = str;

Where var is declared as COleVariant and str as string. m_Nr is an EditBox.

It's just when I try to write to the Database that I get the 'Can't Upd..' error message.

Thanx.
0
erhan_tokerCommented:

// start code

CDaoDatabase *db = new CDaoDatabase ();

m_db->Open ("<your JET/ODBC database>");

CDaoRecordset *rs;

rs = new CDaoRecordset;

// end code

after this step, you should decide which tables, and which fields to use. If your tables can be linked via a common field, set an SQL string which can be done with JOIN statement. If not so, you can not joýn tables, your work must be completed seperately.


// start code
CString sql;
sql = "SELECT * FROM tb1, tb2 INNER JOIN
 tb1.f1 ON tb2.f1 WHERE ....";
// prepare this sql statement for your req.s

rs->Open (sql,  other security parameters....);

// end code

after this step you should be able to edit this recordset.

I hope this helps
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.