Re: Converting ADO.NET DataSet to ADO Recordset - How do I set default values by Paul
Paul
Mon Aug 30 09:27:09 CDT 2004
On 27 Aug 2004 04:09:18 -0700, Bjorn.Egil.Hansen@dnv.com (Bj?rn Egil) wrote:
¤ Paul Clement <UseAdddressAtEndofMessage@swspectrum.com> wrote in message news:<isrji0t563cacntfer6v6o0c93d08ij20c@4ax.com>...
¤ > On 22 Aug 2004 13:56:16 -0700, Bjorn.Egil.Hansen@dnv.com (Bj?rn Egil) wrote:
¤ >
¤ > ¤ Paul Clement <UseAdddressAtEndofMessage@swspectrum.com> wrote in message news:<u3ubi0dduqa9oj9acp85ik0fqa7r1lvuuv@4ax.com>...
¤ > ¤ > On 20 Aug 2004 00:07:01 -0700, Bjorn.Egil.Hansen@dnv.com (Bj?rn Egil) wrote:
¤ > ¤ >
¤ > ¤ > ¤ We
¤ > ¤ > ¤ define the Fields of the Recordset by calling
¤ > ¤ > ¤ aRecordset.Fields.Append(...). However I have not been able to find
¤ > ¤ > ¤ out how I also can set the default value to be used for a Field when
¤ > ¤ > ¤ creating new rows.
¤ > ¤ >
¤ > ¤ > The Field object does not provide a default value property at the Recordset level, only the database
¤ > ¤ > table level with the ADOX Column object.
¤ > ¤ >
¤ > ¤ Hi Paul,
¤ > ¤ Thanks for your reply. Since I'm only working with the Recordset in
¤ > ¤ memory I guess there is no way I can make it pick up the default value
¤ > ¤ from some ADOX Column object or similar?
¤ >
¤ > If you have a Recordset then you have the Fields collection and the Name of each field. You can then
¤ > reference the Default value via ADOX. You also need to know the table name upon which the Recordset
¤ > is based:
¤ >
¤ > Dim cat As New ADOX.Catalog
¤ >
¤ > Set cat.ActiveConnection = cnn
¤ >
¤ > DefaultValue = cat.Tables("Table1").Columns(rs.Fields(0).Name).Properties("Default").Value
¤ >
¤ >
¤ > Paul ~~~ pclement@ameritech.net
¤ > Microsoft MVP (Visual Basic)
¤
¤ Thanks again, Paul,
¤
¤ Sorry for being a bit imprecise in my description: The Recordset is
¤ generated in memory from a DataSet (where I know the default values),
¤ and I would like the to make the Recordset use the same default values
¤ (maybe by setting up a ADOX structure underneath it) so that new
¤ Records added to the Recordset will have these default values
¤ initially.
¤
¤ So is there any way to set up ADOX structure without a connection to a
¤ database?
No, ADOX requires a connection to the database. You can use either an ADO Connection object or a
connection string.
Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)