Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Default Field Values from Oracle

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm having a problem getting default field values from an ADO recordset using Microsoft's ADO Provider. I'm 90% certain I saw this work at some point, but I just can't figure out how to get it to work now. Basically, what I would hope to see is that when I do a .AddNew on the ADO recordset, fields that have a default value would already be populated in the recordset. Here's a piece of code that I am using:

m_oConnection.ConnectionString = _
"Provider=MSDAORA.1;Password=PASSWORD;User ID=USER;Data Source=ALIAS"
m_oConnection.CursorLocation = adUseClient
m_oConnection.Open

Set m_oRS = New Recordset
m_oRS.ActiveConnection = m_oConnection
m_oRS.CursorType = adOpenDynamic
m_oRS.Source = "select * from TABLENAME"
m_oRS.Open

m_oRS.AddNew

================

At this point I would expect to see the database column defaults in the field, but do not. Any suggestions?

Thanks in advance,

Tom
 
Hi Tom,
1)Default field values will work at the time of Insertion. When you fire a insert statement, if any default value doesnt have any value then, database will insert default values.
2) Dont use select * from table. This will fetch all the underlaying data in to recordset. e.g if in that table haveing 1,00,000 records then, it fetches all the records, when call rs.Addnew(), this will add a record at the last of recordset. normally we want empty skeleton not the data.. use where clause to restrict all rows.. like
&quot;where 1 <> 1 &quot; in this case also addnew words.
3) User Insert into values statement rather than addnew...its much faster than rs.Addnew()...
reg
suds...


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top