As a matter of fact, it was the lack of a primary key field that caused the
problem. When I imported the tables and data from my MySQL database, the
primary key fields were not marked as such in the SQL Server tables.
Problem fixed. Thanks!
Silvio
"Simon Hayes" <sql@hayes.ch> wrote in message
news:40c0aeb6$1_3@news.bluewin.ch...[color=blue]
>
> "Silvio Lopes de Oliveira" <silviol@aaesys.com> wrote in message
> news:s91wc.11$5Z4.18584@news.uswest.net...[color=green]
> > Hello,
> >
> > I have a C++ / MFC app which uses CDatabase and CRecordset to connect to[/color][/color]
a[color=blue][color=green]
> > ODBC data source for a SQL Server 7 database. The application worked
> > properly with a MySQL database, but after swapping it for SQL Server
> > problems emerged. In particular, any calls to CRecordset::AddNew() and
> > CRecordset::Edit() cause an exception to be thrown with the error[/color][/color]
message[color=blue][color=green]
> > "Recordset is read-only". Stepping through the code for[/color]
> CRecordset::Open(),[color=green]
> > I can see that it indeeds fail to open the recordset with[/color]
> SQL_CONCUR_ROWVER[color=green]
> > and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I[/color][/color]
need[color=blue]
> to[color=green]
> > be able to write to the db!! What is going on here??
> >
> > I call CRecordset::Open() with no SQL string and no options (which[/color]
> defaults[color=green]
> > to full access and not read-only).
> >
> > I am not a SQL Server expert, but I tried playing with the config a[/color][/color]
little[color=blue][color=green]
> > bit:
> > - The database is NOT set for read-only.
> > - The database option "Restrict Access" is NOT selected.
> > - I checkmarked all permissions (SELECT, INSERT, UPDATE, DELETE,[/color][/color]
DRI)[color=blue][color=green]
> > for my app's user on all tables in the db.
> > - My connection string uses the user 'sa', which is the login name[/color][/color]
for[color=blue][color=green]
> > the user 'dbo'.
> >
> > In the ODBC data source config, I set authentication to SQL Server
> > authentication, and accepted the default for all the other options.
> >
> > I haven't tried using a different class (say, CDaoRecordset) nor do I[/color][/color]
plan[color=blue][color=green]
> > on doing that. I really need to get this to work with CRecordset. Any[/color][/color]
help[color=blue][color=green]
> > is appreciated.
> >
> > Thanks,
> >
> > SL
> >
> >[/color]
>
> This is a guess, but does the table you're working with have a primary[/color]
key?[color=blue]
> Many client tools will not update a table unless there is a primary key
> present, as without a key there is no way to identify the rows you want to
> update. Or if your recordset is returned by a stored procedure you might[/color]
be[color=blue]
> seeing an issue like this:
>
>
http://support.microsoft.com/default...b;en-us;246636
>
> However, I don't do much client-side coding, so I might be on completely[/color]
the[color=blue]
> wrong track here.
>
> Simon
>
>[/color]