This is a multi-part message in MIME format.

------=_NextPart_000_000E_01C3B031.CBF91290
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

How do I retrieve a list of column names in a table using the =
OleDbDataAdapter?

Ian
------=_NextPart_000_000E_01C3B031.CBF91290
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>How do I retrieve a list of column =
names in a table=20
using the </FONT><FONT face=3DArial =
size=3D2>OleDbDataAdapter?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ian</FONT></DIV></BODY></HTML>

------=_NextPart_000_000E_01C3B031.CBF91290--

Re: Retrieving table column by Greg

Greg
Fri Nov 21 15:35:04 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_003D_01C3B04D.6AB73DB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

for each col as datacolumn in table.columns
col.columnname
next
"Ian" <ihinde@hotmail.com> wrote in message =
news:eZfLFPHsDHA.3536@tk2msftngp13.phx.gbl...
How do I retrieve a list of column names in a table using the =
OleDbDataAdapter?

Ian
------=_NextPart_000_003D_01C3B04D.6AB73DB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>for each col as datacolumn in=20
table.columns</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
col.columnname</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>next</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ian" &lt;<A =
href=3D"mailto:ihinde@hotmail.com">ihinde@hotmail.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:eZfLFPHsDHA.3536@tk2msftngp13.phx.gbl">news:eZfLFPHsDHA.3536=
@tk2msftngp13.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>How do I retrieve a list of column =
names in a=20
table using the </FONT><FONT face=3DArial =
size=3D2>OleDbDataAdapter?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>Ian</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_003D_01C3B04D.6AB73DB0--


Re: Retrieving table column by Ian

Ian
Fri Nov 21 17:43:29 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C3B046.35A486C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I assume I need to create a dataset to do this. Is there anyway of =
using SQL just to return the column names without any data?

Ian
"Greg" <greg@cds-am.net> wrote in message =
news:%23$KpkdHsDHA.2084@TK2MSFTNGP12.phx.gbl...
for each col as datacolumn in table.columns
col.columnname
next
"Ian" <ihinde@hotmail.com> wrote in message =
news:eZfLFPHsDHA.3536@tk2msftngp13.phx.gbl...
How do I retrieve a list of column names in a table using the =
OleDbDataAdapter?

Ian
------=_NextPart_000_000B_01C3B046.35A486C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1276" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I assume I need to create a dataset to =
do=20
this.&nbsp; Is there anyway of using SQL just to return the column names =
without=20
any data?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Ian</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Greg" &lt;<A =
href=3D"mailto:greg@cds-am.net">greg@cds-am.net</A>&gt; wrote=20
in message <A=20
=
href=3D"news:%23$KpkdHsDHA.2084@TK2MSFTNGP12.phx.gbl">news:%23$KpkdHsDHA.=
2084@TK2MSFTNGP12.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>for each col as datacolumn in=20
table.columns</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
col.columnname</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>next</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ian" &lt;<A=20
href=3D"mailto:ihinde@hotmail.com">ihinde@hotmail.com</A>&gt; wrote =
in message=20
<A=20
=
href=3D"news:eZfLFPHsDHA.3536@tk2msftngp13.phx.gbl">news:eZfLFPHsDHA.3536=
@tk2msftngp13.phx.gbl</A>...</DIV>
<DIV><FONT face=3DArial size=3D2>How do I retrieve a list of column =
names in a=20
table using the </FONT><FONT face=3DArial=20
size=3D2>OleDbDataAdapter?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>Ian</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000B_01C3B046.35A486C0--


Re: Retrieving table column by news

news
Fri Nov 21 19:18:39 CST 2003

Try this SQL: select Name from syscolumns where id=Object_id('TableName')

--
----------Ñ©ÔÆÓ¥
¾´ÉÏ--------------

MSN:xueyunying@hotmail.com
ÐÅÄî:·ÖÏí֪ʶ¡¢¹²
´´¼¤Çé¡¢¹²Í¬³É¾Í

Blog:http://shanquan.blogone.net
-----------------
-----------------

"Ian" <ihinde@hotmail.com> дÈëÓʼþ
news:eZfLFPHsDHA.3536@tk2msftngp13.phx.gbl...
How do I retrieve a list of column names in a table using the
OleDbDataAdapter?

Ian



Re: Retrieving table column by Miha

Miha
Sat Nov 22 03:07:35 CST 2003

Hi Ian,

Try this:
oleDbConnection1.Open();

DataTable schemaTable =
oleDbConnection1.GetOleDbSchemaTable(OleDbSchemaGuid.Columns,

new object[] {null, null, "YourTableName"});

oleDbConnection1.Close();

All the data is stored into schemaTable.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com

"Ian" <ihinde@hotmail.com> wrote in message
news:eZfLFPHsDHA.3536@tk2msftngp13.phx.gbl...
How do I retrieve a list of column names in a table using the
OleDbDataAdapter?

Ian



Re: Retrieving table column by Paul

Paul
Mon Nov 24 07:40:22 CST 2003

On Fri, 21 Nov 2003 13:17:21 -0800, "Ian" <ihinde@hotmail.com> wrote:

¤ How do I retrieve a list of column names in a table using the OleDbDataAdapter?

You didn't identify the type of database you are using but I've posted an example using VB.NET:

Sub ListTableSchema()

Dim DatabaseConnection As New System.Data.OleDb.OleDbConnection
Dim SchemaTable As DataTable

DatabaseConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=E:\My Documents\db1.mdb"

DatabaseConnection.Open()

'Retrieve schema information about Table1 Columns.
SchemaTable =
DatabaseConnection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Columns, _
New Object() {Nothing, Nothing, "Table1"})

Dim RowCount As Int32
For RowCount = 0 To SchemaTable.Rows.Count - 1
Console.WriteLine(SchemaTable.Rows(RowCount)!COLUMN_NAME.ToString)
Next RowCount

DataGrid1.DataSource = SchemaTable

DatabaseConnection.Close()

End Sub


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