Hello,

I'm working on a project where we are converting between DataSet
(actually DataTable) and Recordset to support existing VB6 code. 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. I appreciate any help in solving this - thanks.

Best regards,
Bjørn Egil Hansen

Re: Converting ADO.NET DataSet to ADO Recordset - How do I set default values by Paul

Paul
Fri Aug 20 08:17:41 CDT 2004

On 20 Aug 2004 00:07:01 -0700, Bjorn.Egil.Hansen@dnv.com (Bj?rn Egil) wrote:

¤ Hello,
¤
¤ I'm working on a project where we are converting between DataSet
¤ (actually DataTable) and Recordset to support existing VB6 code. 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. I appreciate any help in solving this - thanks.
¤
¤ Best regards,
¤ Bjørn Egil Hansen

The Field object does not provide a default value property at the Recordset level, only the database
table level with the ADOX Column object.


Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)

RE: Converting ADO.NET DataSet to ADO Recordset - How do I set default by BradRoberts

BradRoberts
Fri Aug 20 08:57:02 CDT 2004

If the dataset is being populated from a server you could instead use ADODB
from within ASP.NET and the recordset object would be created for you. This
might possibly get the default if it is defined in the server database.

"Bj?rn Egil" wrote:

> Hello,
>
> I'm working on a project where we are converting between DataSet
> (actually DataTable) and Recordset to support existing VB6 code. 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. I appreciate any help in solving this - thanks.
>
> Best regards,
> Bjørn Egil Hansen
>

Re: Converting ADO.NET DataSet to ADO Recordset - How do I set default values by (Bj?rn

(Bj?rn
Sun Aug 22 15:56:16 CDT 2004

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?

Cheers,
Bjørn Egil

Re: Converting ADO.NET DataSet to ADO Recordset - How do I set default values by Paul

Paul
Mon Aug 23 08:37:02 CDT 2004

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)

Re: Converting ADO.NET DataSet to ADO Recordset - How do I set default values by (Bj?rn

(Bj?rn
Fri Aug 27 06:09:18 CDT 2004

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?

Cheers,
Bjørn Egil

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)