Updating recordset

Updating recordset

Post by Eb » Sat, 14 Jul 2001 21:02:11



All,

I observered some interesting behavior using ADO with Oracle and SQL Server
and I need some clarity.

For example, if a field A is defined as datatype varchar2(25) in both Oracle
and SQL and is used to initialize a disconnected recordset, and you try to
set the value of the field to a string larger than 25 characters, SQL Server
errors out with an error message, whereas Oracle sets the value of the
field.

Pseudocode
String myString = [string larger that 25 xters]
Recordset rs = Select A from B
rs.getField(0).setString(myString); works in Oracle, but not in SQL Server

Is this a bug in SQL Server or Oracle?  Or this just intended behavior by
the different providers?  Has anyone seen this, or is there a known
workaround?

Thanks
Eb

 
 
 

Updating recordset

Post by Erland Sommarsko » Sat, 14 Jul 2001 22:14:28


[posted and mailed, please reply in news]


> For example, if a field A is defined as datatype varchar2(25) in both Oracle
> and SQL and is used to initialize a disconnected recordset, and you try to
> set the value of the field to a string larger than 25 characters, SQL Server
> errors out with an error message, whereas Oracle sets the value of the
> field.

> Pseudocode
> String myString = [string larger that 25 xters]
> Recordset rs = Select A from B
> rs.getField(0).setString(myString); works in Oracle, but not in SQL Server

> Is this a bug in SQL Server or Oracle?  

No, it's a bug in Oracle. :-)

Seriously, for SQL Server you have a choice. With SET ANSI_WARNINGS ON
you will get an error when you try to squeeze in too many characters
in a column. With the setting off, the value will silently be truncated.
The default setting in SQL Server is OFF, but ADO turns this setting
on by default.

As for Oracle, I don't know anything, but as you can guess from the
name of the setting, giving an error is ANSI compliant.

--
Erland Sommarskog, Abaris AB

SQL Server MVP

 
 
 

1. open recordset, change connection, update recordset?

Can this work - if so how?!

I've pulled out a huge recordset, I set activeconnection to nothing, then
set it to my new connection - hit updatebatch - no errors or anything, but
no new records in the second database either.

I don't really want to have to do each field by hand - there's hundreds of
them :)

Any ideas how to make this work?

2. xp_readmail

3. Updating RecordSet with values of a second RecordSet

4. Disaster recovery

5. Updating recordsets returned from a recordset stack

6. Book Book

7. When updating recordset I get error -2147467259 (to many rows affected by update)

8. Distribution of Zephyr?

9. Update TextBox, Update Recordset, Out of Sync When Using Code

10. SQL/VC++ Updates: Can't update recordset

11. Update recordset with Update Batch

12. Updating textbox via code not updating recordset

13. updating recordset returned by parameterized stored procedure