HighTechTalks DotNet Forums  

ADOX and C# problems

Dotnet Framework (ODBC.net) microsoft.public.dotnet.framework.odbcnet


Discuss ADOX and C# problems in the Dotnet Framework (ODBC.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Enzo
 
Posts: n/a

Default ADOX and C# problems - 07-01-2004 , 07:36 PM






The following code:

ADOX.Catalog mdb = new ADOX.CatalogClass();
try
{
mdb.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + mdbPath + @"\" + mdbName + ";" +
"Jet OLEDB:Engine Type=5");

ADOX.Table mdbTbl = new ADOX.TableClass();
mdbTbl.Name = "Receivers";
mdbTbl.Columns.Append("AddressBookID", ADOX.DataTypeEnum.adDecimal,9);
mdb.Tables.Append(mdbTbl);
}
catch(Exception ex)
{
Trace.WriteLine(ex.Source);
Trace.WriteLine(ex.Message);
Trace.WriteLine(ex.InnerException);
}

This code throws an exception telling me that it is an invalid type. But I am using the the ADOX Enum so what is the problem?

Thank you




Reply With Quote
  #2  
Old   
Paul Clement
 
Posts: n/a

Default Re: ADOX and C# problems - 07-06-2004 , 03:40 PM






On Thu, 1 Jul 2004 16:36:01 -0700, "Enzo" <enzomaini (AT) dotnetfan (DOT) net> wrote:

¤ The following code:
¤
¤ ADOX.Catalog mdb = new ADOX.CatalogClass();
¤ try
¤ {
¤ mdb.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
¤ "Data Source=" + mdbPath + @"\" + mdbName + ";" +
¤ "Jet OLEDB:Engine Type=5");
¤
¤ ADOX.Table mdbTbl = new ADOX.TableClass();
¤ mdbTbl.Name = "Receivers";
¤ mdbTbl.Columns.Append("AddressBookID", ADOX.DataTypeEnum.adDecimal,9);
¤ mdb.Tables.Append(mdbTbl);
¤ }
¤ catch(Exception ex)
¤ {
¤ Trace.WriteLine(ex.Source);
¤ Trace.WriteLine(ex.Message);
¤ Trace.WriteLine(ex.InnerException);
¤ }
¤
¤ This code throws an exception telling me that it is an invalid type. But I am using the the ADOX Enum so what is the problem?

adDecimal does not map to an Access data type. Try adCurrency instead. If this isn't the correct
data type you may want to indicate what the data type of the column is when viewing in Access.


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)

Reply With Quote
  #3  
Old   
Enzo
 
Posts: n/a

Default Re: ADOX and C# problems - 07-07-2004 , 07:18 PM



The problem was with the FoxPro application that originally created the file. It marked the field as float.

"Paul Clement" wrote:

Quote:
On Thu, 1 Jul 2004 16:36:01 -0700, "Enzo" <enzomaini (AT) dotnetfan (DOT) net> wrote:

¤ The following code:
¤
¤ ADOX.Catalog mdb = new ADOX.CatalogClass();
¤ try
¤ {
¤ mdb.Create("Provider=Microsoft.Jet.OLEDB.4.0;" +
¤ "Data Source=" + mdbPath + @"\" + mdbName + ";" +
¤ "Jet OLEDB:Engine Type=5");
¤
¤ ADOX.Table mdbTbl = new ADOX.TableClass();
¤ mdbTbl.Name = "Receivers";
¤ mdbTbl.Columns.Append("AddressBookID", ADOX.DataTypeEnum.adDecimal,9);
¤ mdb.Tables.Append(mdbTbl);
¤ }
¤ catch(Exception ex)
¤ {
¤ Trace.WriteLine(ex.Source);
¤ Trace.WriteLine(ex.Message);
¤ Trace.WriteLine(ex.InnerException);
¤ }
¤
¤ This code throws an exception telling me that it is an invalid type. But I am using the the ADOX Enum so what is the problem?

adDecimal does not map to an Access data type. Try adCurrency instead. If this isn't the correct
data type you may want to indicate what the data type of the column is when viewing in Access.


Paul ~~~ pclement (AT) ameritech (DOT) net
Microsoft MVP (Visual Basic)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.