Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Monday, March 26, 2012

Recovering unused space on Sql 7.0 tables

Hi List,
I have 4 tables with 20+million rows (3rd party app) anyway these tables are
reporting their space used in the 50+gigabytes but the space they are
claiming is about 70-90 gb is there anyway to force them to shrink to
recover this space.
thanks
evanDepends on how the database files were created. SS 7.0 is kind of PITA
regarding file management... It's one of the main reasons to upgrade to
SS2K.
Anyway, execute the following from within the database you are discribing to
get an accurate representation:
EXECUTE sp_spaceused @.updateusage = 'true'
EXECUTE sp_helpdb 'MyDatabase'
Now, use the DBCC SHRINKFILE command to reclaim the space you desire on the
data files. SS 7.0 space reclaimation on the transaction logs is lousy.
More often than not, you have to detach the database, move the transaction
log somewhere else, then use the sp_attach_single_file_db to have the
database brought back online with a newly created, and hopefully smaller,
transaction log.
Hope this helps.
Sincerely,
Anthony Thomas
"evan b" <evan_at_cheapaschips.com.au_removethis> wrote in message
news:OGlnIj52EHA.1404@.TK2MSFTNGP11.phx.gbl...
Hi List,
I have 4 tables with 20+million rows (3rd party app) anyway these tables are
reporting their space used in the 50+gigabytes but the space they are
claiming is about 70-90 gb is there anyway to force them to shrink to
recover this space.
thanks
evan

Recovering unused space on Sql 7.0 tables

Hi List,
I have 4 tables with 20+million rows (3rd party app) anyway these tables are
reporting their space used in the 50+gigabytes but the space they are
claiming is about 70-90 gb is there anyway to force them to shrink to
recover this space.
thanks
evan
Depends on how the database files were created. SS 7.0 is kind of PITA
regarding file management... It's one of the main reasons to upgrade to
SS2K.
Anyway, execute the following from within the database you are discribing to
get an accurate representation:
EXECUTE sp_spaceused @.updateusage = 'true'
EXECUTE sp_helpdb 'MyDatabase'
Now, use the DBCC SHRINKFILE command to reclaim the space you desire on the
data files. SS 7.0 space reclaimation on the transaction logs is lousy.
More often than not, you have to detach the database, move the transaction
log somewhere else, then use the sp_attach_single_file_db to have the
database brought back online with a newly created, and hopefully smaller,
transaction log.
Hope this helps.
Sincerely,
Anthony Thomas

"evan b" <evan_at_cheapaschips.com.au_removethis> wrote in message
news:OGlnIj52EHA.1404@.TK2MSFTNGP11.phx.gbl...
Hi List,
I have 4 tables with 20+million rows (3rd party app) anyway these tables are
reporting their space used in the 50+gigabytes but the space they are
claiming is about 70-90 gb is there anyway to force them to shrink to
recover this space.
thanks
evan

Tuesday, March 20, 2012

Recover Image From SQL Server CE Database

Hello,

Im using the same DB used in northwindoledb example, i need a similar app but in C#, not C++, so i use this DB and make a form for Pocket PC 2003 SE Emulator in Vista (device application) with visual studio 2005, i use a function to recover the image and display in a PictureBox but when this image create a BitMap give me an error "Value does not fall within the expected range.", i seek a lot in internet and don't find a solution, the function is:

public static Image Bytes2Image(byte[] bytes)

{

if (bytes == null) return null;

MemoryStream ms = new MemoryStream(bytes,0,bytes.Length );

Bitmap bm = null;

ms.Read(bytes, 0, bytes.Length);

bm = new Bitmap(ms);

return bm;

}

If someone can help me i will appreciatte

How about:

Code Snippet

public System.Drawing.Image BytesToImage(byte[] bytes)

{

if (bytes == null) return null;

System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);

return System.Drawing.Image.FromStream(ms);

}

|||

Erik,

System.Drawing.Image.FromStream(ms);

Don't exist in Compact Framework, all post suggest the use of new Bitmap(ms) instead, but this code give the error... Other user have similar error but cannot find the solution, the C++ version of the program work ok in the emulator, but in C# don't work (i'm using different aproach, i don't understand C++), some have a similar program in C# than manipulate images from SQL 2005 CE for Pocket PC?

Recover Image From SQL Server CE Database

Hello,

Im using the same DB used in northwindoledb example, i need a similar app but in C#, not C++, so i use this DB and make a form for Pocket PC 2003 SE Emulator in Vista (device application) with visual studio 2005, i use a function to recover the image and display in a PictureBox but when this image create a BitMap give me an error "Value does not fall within the expected range.", i seek a lot in internet and don't find a solution, the function is:

public static Image Bytes2Image(byte[] bytes)

{

if (bytes == null) return null;

MemoryStream ms = new MemoryStream(bytes,0,bytes.Length );

Bitmap bm = null;

ms.Read(bytes, 0, bytes.Length);

bm = new Bitmap(ms);

return bm;

}

If someone can help me i will appreciatte

How about:

Code Snippet

public System.Drawing.Image BytesToImage(byte[] bytes)

{

if (bytes == null) return null;

System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);

return System.Drawing.Image.FromStream(ms);

}

|||

Erik,

System.Drawing.Image.FromStream(ms);

Don't exist in Compact Framework, all post suggest the use of new Bitmap(ms) instead, but this code give the error... Other user have similar error but cannot find the solution, the C++ version of the program work ok in the emulator, but in C# don't work (i'm using different aproach, i don't understand C++), some have a similar program in C# than manipulate images from SQL 2005 CE for Pocket PC?

Wednesday, March 7, 2012

Recordset opens as read-only -- WHY?

Hello,
I have a C++ / MFC app which uses CDatabase and CRecordset to connect to a
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 message
"Recordset is read-only". Stepping through the code for CRecordset::Open(),
I can see that it indeeds fail to open the recordset with SQL_CONCUR_ROWVER
and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need to
be able to write to the db!! What is going on here?
I call CRecordset::Open() with no SQL string and no options (which defaults
to full access and not read-only).
I am not a SQL Server expert, but I tried playing with the config a little
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, DRI)
for my app's user on all tables in the db.
- My connection string uses the user 'sa', which is the login name for
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 plan
on doing that. I really need to get this to work with CRecordset. Any help
is appreciated.
Thanks,
SL
"Silvio Lopes de Oliveira" <silviol@.aaesys.com> wrote in message
news:s91wc.11$5Z4.18584@.news.uswest.net...
> Hello,
> I have a C++ / MFC app which uses CDatabase and CRecordset to connect to a
> 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 message
> "Recordset is read-only". Stepping through the code for
CRecordset::Open(),
> I can see that it indeeds fail to open the recordset with
SQL_CONCUR_ROWVER
> and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need
to
> be able to write to the db!! What is going on here?
> I call CRecordset::Open() with no SQL string and no options (which
defaults
> to full access and not read-only).
> I am not a SQL Server expert, but I tried playing with the config a little
> 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, DRI)
> for my app's user on all tables in the db.
> - My connection string uses the user 'sa', which is the login name for
> 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 plan
> on doing that. I really need to get this to work with CRecordset. Any help
> is appreciated.
> Thanks,
> SL
>
This is a guess, but does the table you're working with have a primary key?
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 be
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 the
wrong track here.
Simon
|||Silvio Lopes de Oliveira (silviol@.aaesys.com) writes:
> I have a C++ / MFC app which uses CDatabase and CRecordset to connect to
> a 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
> message "Recordset is read-only". Stepping through the code for
> CRecordset::Open(), I can see that it indeeds fail to open the recordset
> with SQL_CONCUR_ROWVER and SQL_CONCUR_LOCK, finally succeeding with
> SQL_CONCUR_READ_ONLY. I need to be able to write to the db!! What is
> going on here?
It would have helped if you had posted the query.
I would guess that the reason is that the query is such that SQL
Server will not be able to determine which row to update. This
could be because, as Simon pointed out, of a missing primary key.
But it can also happen if you use GROUP BY, expressions or a whole
load number of things.
When this happens to people in their stored procedures, I recommend
them to not use WHERE CURRENT OF, but use a regular WHERE clause
instead. In your case, this would mean that you would submit a
regular UPDATE statement. But I guess that would be through a
different connection, because the one where you have the cursor
may be busy. And depending on which locking scheme you have on your
cursor, you may look yourself.
The remedy for this would be to get all data into the client, and
the close the cursor, and then you can update from the regular
connection. Unless the amount of data is huge, this is likely to
be more effecient. (And if the amount of data is huge, then using a
stored procedure with all the update logic and never get the data
to he client, would be a big winner.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
|||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...[vbcol=seagreen]
> "Silvio Lopes de Oliveira" <silviol@.aaesys.com> wrote in message
> news:s91wc.11$5Z4.18584@.news.uswest.net...
a[vbcol=seagreen]
message[vbcol=seagreen]
> CRecordset::Open(),
> SQL_CONCUR_ROWVER
need[vbcol=seagreen]
> to
> defaults
little[vbcol=seagreen]
DRI)[vbcol=seagreen]
for[vbcol=seagreen]
plan[vbcol=seagreen]
help
> This is a guess, but does the table you're working with have a primary
key?
> 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
be
> 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
the
> wrong track here.
> Simon
>

Recordset opens as read-only -- WHY?

Hello,

I have a C++ / MFC app which uses CDatabase and CRecordset to connect to a
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 message
"Recordset is read-only". Stepping through the code for CRecordset::Open(),
I can see that it indeeds fail to open the recordset with SQL_CONCUR_ROWVER
and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need to
be able to write to the db!! What is going on here??

I call CRecordset::Open() with no SQL string and no options (which defaults
to full access and not read-only).

I am not a SQL Server expert, but I tried playing with the config a little
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, DRI)
for my app's user on all tables in the db.
- My connection string uses the user 'sa', which is the login name for
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 plan
on doing that. I really need to get this to work with CRecordset. Any help
is appreciated.

Thanks,

SL"Silvio Lopes de Oliveira" <silviol@.aaesys.com> wrote in message
news:s91wc.11$5Z4.18584@.news.uswest.net...
> Hello,
> I have a C++ / MFC app which uses CDatabase and CRecordset to connect to a
> 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 message
> "Recordset is read-only". Stepping through the code for
CRecordset::Open(),
> I can see that it indeeds fail to open the recordset with
SQL_CONCUR_ROWVER
> and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need
to
> be able to write to the db!! What is going on here??
> I call CRecordset::Open() with no SQL string and no options (which
defaults
> to full access and not read-only).
> I am not a SQL Server expert, but I tried playing with the config a little
> 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, DRI)
> for my app's user on all tables in the db.
> - My connection string uses the user 'sa', which is the login name for
> 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 plan
> on doing that. I really need to get this to work with CRecordset. Any help
> is appreciated.
> Thanks,
> SL

This is a guess, but does the table you're working with have a primary key?
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 be
seeing an issue like this:

http://support.microsoft.com/defaul...kb;en-us;246636

However, I don't do much client-side coding, so I might be on completely the
wrong track here.

Simon|||Silvio Lopes de Oliveira (silviol@.aaesys.com) writes:
> I have a C++ / MFC app which uses CDatabase and CRecordset to connect to
> a 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
> message "Recordset is read-only". Stepping through the code for
> CRecordset::Open(), I can see that it indeeds fail to open the recordset
> with SQL_CONCUR_ROWVER and SQL_CONCUR_LOCK, finally succeeding with
> SQL_CONCUR_READ_ONLY. I need to be able to write to the db!! What is
> going on here??

It would have helped if you had posted the query.

I would guess that the reason is that the query is such that SQL
Server will not be able to determine which row to update. This
could be because, as Simon pointed out, of a missing primary key.
But it can also happen if you use GROUP BY, expressions or a whole
load number of things.

When this happens to people in their stored procedures, I recommend
them to not use WHERE CURRENT OF, but use a regular WHERE clause
instead. In your case, this would mean that you would submit a
regular UPDATE statement. But I guess that would be through a
different connection, because the one where you have the cursor
may be busy. And depending on which locking scheme you have on your
cursor, you may look yourself.

The remedy for this would be to get all data into the client, and
the close the cursor, and then you can update from the regular
connection. Unless the amount of data is huge, this is likely to
be more effecient. (And if the amount of data is huge, then using a
stored procedure with all the update logic and never get the data
to he client, would be a big winner.)

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||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...
> "Silvio Lopes de Oliveira" <silviol@.aaesys.com> wrote in message
> news:s91wc.11$5Z4.18584@.news.uswest.net...
> > Hello,
> > I have a C++ / MFC app which uses CDatabase and CRecordset to connect to
a
> > 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
message
> > "Recordset is read-only". Stepping through the code for
> CRecordset::Open(),
> > I can see that it indeeds fail to open the recordset with
> SQL_CONCUR_ROWVER
> > and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I
need
> to
> > be able to write to the db!! What is going on here??
> > I call CRecordset::Open() with no SQL string and no options (which
> defaults
> > to full access and not read-only).
> > I am not a SQL Server expert, but I tried playing with the config a
little
> > 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,
DRI)
> > for my app's user on all tables in the db.
> > - My connection string uses the user 'sa', which is the login name
for
> > 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
plan
> > on doing that. I really need to get this to work with CRecordset. Any
help
> > is appreciated.
> > Thanks,
> > SL
> This is a guess, but does the table you're working with have a primary
key?
> 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
be
> seeing an issue like this:
> http://support.microsoft.com/defaul...kb;en-us;246636
> However, I don't do much client-side coding, so I might be on completely
the
> wrong track here.
> Simon

Recordset opens as read-only -- WHY?

Hello,
I have a C++ / MFC app which uses CDatabase and CRecordset to connect to a
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 message
"Recordset is read-only". Stepping through the code for CRecordset::Open(),
I can see that it indeeds fail to open the recordset with SQL_CONCUR_ROWVER
and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need to
be able to write to the db!! What is going on here'
I call CRecordset::Open() with no SQL string and no options (which defaults
to full access and not read-only).
I am not a SQL Server expert, but I tried playing with the config a little
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, DRI)
for my app's user on all tables in the db.
- My connection string uses the user 'sa', which is the login name for
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 plan
on doing that. I really need to get this to work with CRecordset. Any help
is appreciated.
Thanks,
SL"Silvio Lopes de Oliveira" <silviol@.aaesys.com> wrote in message
news:s91wc.11$5Z4.18584@.news.uswest.net...
> Hello,
> I have a C++ / MFC app which uses CDatabase and CRecordset to connect to a
> 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 message
> "Recordset is read-only". Stepping through the code for
CRecordset::Open(),
> I can see that it indeeds fail to open the recordset with
SQL_CONCUR_ROWVER
> and SQL_CONCUR_LOCK, finally succeeding with SQL_CONCUR_READ_ONLY. I need
to
> be able to write to the db!! What is going on here'
> I call CRecordset::Open() with no SQL string and no options (which
defaults
> to full access and not read-only).
> I am not a SQL Server expert, but I tried playing with the config a little
> 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, DRI)
> for my app's user on all tables in the db.
> - My connection string uses the user 'sa', which is the login name for
> 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 plan
> on doing that. I really need to get this to work with CRecordset. Any help
> is appreciated.
> Thanks,
> SL
>
This is a guess, but does the table you're working with have a primary key?
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 be
seeing an issue like this:
http://support.microsoft.com/defaul...kb;en-us;246636
However, I don't do much client-side coding, so I might be on completely the
wrong track here.
Simon|||Silvio Lopes de Oliveira (silviol@.aaesys.com) writes:
> I have a C++ / MFC app which uses CDatabase and CRecordset to connect to
> a 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
> message "Recordset is read-only". Stepping through the code for
> CRecordset::Open(), I can see that it indeeds fail to open the recordset
> with SQL_CONCUR_ROWVER and SQL_CONCUR_LOCK, finally succeeding with
> SQL_CONCUR_READ_ONLY. I need to be able to write to the db!! What is
> going on here'
It would have helped if you had posted the query.
I would guess that the reason is that the query is such that SQL
Server will not be able to determine which row to update. This
could be because, as Simon pointed out, of a missing primary key.
But it can also happen if you use GROUP BY, expressions or a whole
load number of things.
When this happens to people in their stored procedures, I recommend
them to not use WHERE CURRENT OF, but use a regular WHERE clause
instead. In your case, this would mean that you would submit a
regular UPDATE statement. But I guess that would be through a
different connection, because the one where you have the cursor
may be busy. And depending on which locking scheme you have on your
cursor, you may look yourself.
The remedy for this would be to get all data into the client, and
the close the cursor, and then you can update from the regular
connection. Unless the amount of data is huge, this is likely to
be more effecient. (And if the amount of data is huge, then using a
stored procedure with all the update logic and never get the data
to he client, would be a big winner.)
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||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...
> "Silvio Lopes de Oliveira" <silviol@.aaesys.com> wrote in message
> news:s91wc.11$5Z4.18584@.news.uswest.net...
a[vbcol=seagreen]
message[vbcol=seagreen]
> CRecordset::Open(),
> SQL_CONCUR_ROWVER
need[vbcol=seagreen]
> to
> defaults
little[vbcol=seagreen]
DRI)[vbcol=seagreen]
for[vbcol=seagreen]
plan[vbcol=seagreen]
help[vbcol=seagreen]
> This is a guess, but does the table you're working with have a primary
key?
> 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
be
> seeing an issue like this:
> http://support.microsoft.com/defaul...kb;en-us;246636
> However, I don't do much client-side coding, so I might be on completely
the
> wrong track here.
> Simon
>

Monday, February 20, 2012

Recordcount Issue

This is weird. I have (identical) copies of sql server running on two seperate machines. I have a vb app that accesses the data. It runs with both dbs but I have the following function that I call to show the record count in a particular display:

Code:------------------------

Dim rs As Recordset

'determines number of records in a sql statement
Set rs = New ADODB.Recordset
rs.Open sql, conn, adOpenStatic, adLockOptimistic
RecordCount = rs.RecordCount
rs.Close
Set rs = Nothing

------------------------With one db it works just fine but with the other it returns a value of -1 even though the data is displayed just fine. Any ideas?You need to make sure that you have a client side sursor for this to work.

I always work with disconnected recorsets so it's not an issue.|||I'm not a VB expert, but I think you need to use rs.movelast in order to get an accurate count.

blindman