Welcome to MSDN Blogs Sign in | Join | Help

using GetSchema() for columns collection in schema

GetSchema(<schema name>), using the schema mapping name of the table.

e.g.

try{

//Create connection

HostFileConnection cn = new HostFileConnection();

cn.ConnectionString = cnstring;

cn.Open();

DataTable dtcn2 = cn.GetSchema("Tables");

a = 0;

foreach (DataRow r in dtcn2.Rows)

{

object[] items = dtcn2.Rows[a].ItemArray;

a++;

int z = items.Length;

for (int z1 = 0; z1 < z; z1++)

{

DataTable dt = cn.GetSchema(items[0].ToString());

//DataTable dt = cn.GetSchema("Tables", new string[] { items[0].ToString() });

//DataTable dt = cn.GetSchema("Columns", new string[] { items[0].ToString() });

if (dt.HasErrors)

// error handling  

}}}}

catch (Exception e)

{ }

finally

{ cn.Close();}

 

Probable Exception you may get is :

The requested collection (TableName) is not defined.

This is because GetSchema in an assembly is valid call only for Schemas not for Table. 

Published Wednesday, September 13, 2006 7:16 PM by asmitaw

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker