PC Review


Reply
Thread Tools Rate Thread

Access2K Oledb DataView: DefaultValue Unique AllowDBNull properties

 
 
AndreaJ@antispam.biz
Guest
Posts: n/a
 
      25th Jul 2003
When an OleDb dataview is instantiated using (Select * from
MyAccess2000Table), why aren't the following datacolumn properties
accurately exposed:

Unique
AllowDBNull
DefaultValue

Dim Col As DataColumn
For Each Col In MyDataView.Table.Columns
Col.Unique
Col.AllowDBNull
Col.DefaultValue
Next

When I test these values at runtime, they do not reflect the state of my
Access table. Doesn't the JET4.0 Provider surface them to the DataView?

TIA



 
Reply With Quote
 
 
 
 
Joe Fallon
Guest
Posts: n/a
 
      26th Jul 2003
I hard coded the default value in my table building code.
(Don't know about anyone else.)

I use code like this to build my datatables.

Public Function GenMissingItemsTable() As DataTable
Dim dt As New DataTable("dtMissingItems")
Dim col As DataColumn
With dt.Columns
col = .Add("itemno", GetType(String))
col.MaxLength = 25
col.AllowDBNull = False
col = .Add("descr1", GetType(String))
col.MaxLength = 60
col.AllowDBNull = False
col = .Add("uom", GetType(String))
col.MaxLength = 3
col.AllowDBNull = False
End With
dt.PrimaryKey = New DataColumn() {dt.Columns("itemno")}

Return dt
End Function

--
Joe Fallon



<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for the code snippet, Joe. But I'm not out of the woods yet. The
> FillSchema() method doesn't configure the DefaultValue property.
> So how do I get the important default value? Or even find out if there
> is one?
>
> I must allow the record to be written to the row with a blank column
> value, even if that column has AllowDBNull = False, when the column has
> a default value. But I cannot find out by examining the schema if there
> is a default value set for the column.
>
> Is everyone hard-coding default values into the front-end? That would be
> a maintenance problem if the default-value should change.
>
> Andi
>
> > Unique
> > AllowDBNull
> > DefaultValue
> >
> > Dim Col As DataColumn
> > For Each Col In MyDataView.Table.Columns
> > Col.Unique
> > Col.AllowDBNull
> > Col.DefaultValue
> > Next

>
>
> In article <#(E-Mail Removed)>, jfallon1
> @nospamtwcny.rr.com says...
> > [snip important stuff]
> >Public Sub GetSchema(ByRef dt As DataTable, _
> > ByVal strSQL As String, _
> > ByVal DBtype As String)
> > 'retrieve structure information into a datatable using the FillSchema
> > ' method of a DataAdapter object
> > ...<snip>
> > ElseIf DBtype = "OLEDB" Then
> > Dim cnn As New OleDbConnection(mConnStr)
> > Try
> > cnn.Open()
> > 'KB309488 - the Object array is for filtering the returned

data
> > (only TABLEs are returned not Views, etc.)
> > dt = cnn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, New

Object()
> > {Nothing, Nothing, Nothing, "TABLE"})
> > Finally
> > cnn.Close()
> > End Try
> > End If
> > End Sub
> >
> >



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DefaultValue attribute on properties of user controls michael sorens Microsoft C# .NET 5 6th Jun 2008 07:59 AM
How to read workbook (not worksheet) properties with OLEDB 4everDad Microsoft Excel Worksheet Functions 7 5th Mar 2008 01:58 PM
How to read workbook (not worksheet) properties with OLEDB ForeverDad Microsoft Excel Programming 0 29th Feb 2008 11:52 PM
OleDb: Get Properties Armin Zingler Microsoft ADO .NET 5 24th Jun 2005 05:11 AM
Re: non-unique indexes / dataview William \(Bill\) Vaughn Microsoft ADO .NET 3 17th Jul 2003 01:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:50 PM.