Re: Get schema?



Ben,

Here is an example that displays all the column names. You can modify it to
create a comma-separated list:

Private Sub DisplayColumns(ByVal ConnectionString As String, ByVal
TableName As String)

Dim cn As New OleDb.OleDbConnection(ConnectionString)
Dim cmd As New OleDb.OleDbCommand
Dim rdr As OleDb.OleDbDataReader
Dim tbl As DataTable

cmd.CommandText = "Select * From " & TableName
cn.Open()
cmd.Connection = cn
rdr = cmd.ExecuteReader(CommandBehavior.SchemaOnly Or
CommandBehavior.KeyInfo)
tbl = rdr.GetSchemaTable
rdr.Close()

Dim row As DataRow
For Each row In tbl.Rows
MsgBox(row("ColumnName"))
Next

End Sub

Kerry Moorman




"Ben Wallace (3)" wrote:

> Thanks, for the replys. My main goal is to contruct an SQL statement baseD
> on the schema, using the fields IN an UPDATE statement, how can I get the
> field names from the schema table, and creat a comma seperated list
> (field1,field2,field3 ....etc...), a loop possibly?
>
> Thanks
>
>
>
>
>
> "Russell Verdun" <cpa44@xxxxxxxxxxx> wrote in message
> news:%23pkHPFAiFHA.572@xxxxxxxxxxxxxxxxxxxxxxx
> >I hope someone can advise on a solution....how can I obtain schema
> > information, column names to be exact, from a SQL, Oracle table via
> > ado.net.
> > I need to gather the column names from a given table.
> >
> > Thank you.
> >
> >
> >
> >
>
>
>
.



Relevant Pages

  • Re: Method of Data Member Not found
    ... Private Sub Command21_Click ... Dim SQLstrg As String ... will build the SQL statement, ...
    (microsoft.public.access.forms)
  • Re: Multi-Select ListBox
    ... You have not closed the qdf so the Query has not been updated with the ... whatever was saved in the previously saved Query and not the SQL String you ... > Private Sub cmdOK_Click ... > ' Build the new SQL statement incorporating the string ...
    (microsoft.public.access.forms)
  • Re: Multi-Select ListBox
    ... ' Apply the new SQL statement to the query ... the selected values are then used as query criteria. ... >> Private Sub cmdOK_Click ... >> ' Remove the leading comma from the string ...
    (microsoft.public.access.forms)
  • Re: Playing AVI and MPEG using MCI
    ... "mciSendStringA" (ByVal lpstrCommand As String, ... Dim mlRet As Long ... Private Sub CenterObject ... If mlRet 0 Then ...
    (microsoft.public.vb.controls)
  • RE: Adding Bound Pictures to an Access Database
    ... when the student's picture is missing it is leaving the ... Private Sub Form_Current ... Dim strPath As String ... Private Function pfValidFile(aFile As String) As Boolean ...
    (microsoft.public.access.modulesdaovba)