Hi Ron,
Because this is the microsoft.public.access.adp.sqlserver newsgroup,
people are likely to assume that you're working with an Access ADP (which
would mean that the data was stored in SQL Server) unless you state
otherwise.
The Access/Jet system tables are undocumented. While some people have
managed to figure out how to extract various information from them, I have
not heard of any way to extract field names for a specified table. When I
look at the system tables in an Access MDB, I don't see anything that
looks like field names. Perhaps this information may be stored as binary
data in one of the various OLE Object fields in the system tables, but
that's just a guess on my part.
One way to get this information in a .NET app would be to use the
FillSchema method of the DataSet object ...
using System;
using System.Data;
using System.Data.OleDb;
namespace ConsoleApplication16
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;"
+ @"Data Source=c:\dsdata\northwind.mdb;"
+ @"Persist Security Info=False";
OleDbConnection connection = new System.Data.OleDb
.OleDbConnection(connectionString);
OleDbCommand selectCommand = new System.Data.OleDb
.OleDbCommand("SELECT * FROM Categories", connection);
OleDbDataAdapter dataAdapter = new System.Data.OleDb
.OleDbDataAdapter(selectCommand);
DataSet dataSet = new System.Data.DataSet();
dataAdapter.FillSchema(dataSet,System.Data.SchemaType.Source);
DataColumnCollection columns = dataSet.Tables[0].Columns;
foreach (System.Data.DataColumn dataColumn in columns)
{
Console.WriteLine(dataColumn.ColumnName);
}
Console.ReadLine();
}
}
}
--
Brendan Reynolds (MVP)
Ron Dahl said:
I forgot to mention quite a few things. I am using vb DotNet and creating
a DataAdapter and DataSet at runtime. It appears that RowSourceType and
RowSource are properties of the MS Access object, and I wasn't setting any
reference to MS Access. Is there an SQL statement that I could use
similar to "Select FieldList from MyTable".
I apologize if I misunderstood your reply, but I can't find any
RowSourceType or RowSource for my listbox in VB DotNet.
Thanks
Ron Dahl