Retrieving the default-value for a field in an Access-table

O

Olaf Rabbachin

Hi folks,

I'm looking for a way of retrieving the default-value of a table's field
within an Access 2003 MDB.
Any hints on how to accomplish this from ASP.Net?

Thanks,
Olaf
 
O

Olaf Rabbachin

Hi,

Olaf said:
I'm looking for a way of retrieving the default-value of a table's field
within an Access 2003 MDB.
Any hints on how to accomplish this from ASP.Net?

got it (although not all too satisfying - see below).
Here's some code that'll display all columns within a given table along
with their default-values:

--- 8< ---
Dim cn As New OleDbConnection
cn.ConnectionString = "Whatever ..."
cn.Open()

Dim tbl As DataTable
tbl = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, "Name of Table", Nothing})

For Each r As DataRow In tbl.Rows
Response.Write _
r("COLUMN_NAME") & ": " & _
r("COLUMN_DEFAULT") & "<br />"
Next
--- 8< ---

If anybody has a more appropriate way of retrieving this by a column's name
(rather than looping through all columns), let me know!

Cheers,
Olaf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top