dbTalk Databases Forums  

DAO TableDef and SQL Server

microsoft.public.sqlserver.programming microsoft.public.sqlserver.programming


Discuss DAO TableDef and SQL Server in the microsoft.public.sqlserver.programming forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Sean
 
Posts: n/a

Default DAO TableDef and SQL Server - 03-06-2006 , 10:13 AM






I working on an existing app that uses DAO to connect to Access
databases. I am trying to update this app to allow the use of SQL
Server databases. At one point, we create a TableDef object for one of
the tables, then loop through the fields, looking at the TableDef.Type
with a Case statement and then acting accordingly. The problem is, the
TableDef.Type for SQL Server fields is not the same as for the Access
fields. So, I began debugging the code to get the values, but the
problem is that the Type is inconsistent. Nvarchar fields have a
TableDef.Type of 56 when running the program one time, but other times
have types of 57, 62, 60, etc. Is there a reason these are not
consistent? Is there a range of values that the types fall into? I'm
looking for a resource that shows the TableDef.Type values for SQL
Server field datatypes. Anyone know where I can find this?


Reply With Quote
  #2  
Old   
JT
 
Posts: n/a

Default Re: DAO TableDef and SQL Server - 03-06-2006 , 11:24 AM






Consider using ADO rather than DAO. DAO was superceeded back in 98, and the
documentation on MSDN is spotty.
http://msdn.microsoft.com/library/de...essingdata.asp

"Sean" <nbSean (AT) gmail (DOT) com> wrote

Quote:
I working on an existing app that uses DAO to connect to Access
databases. I am trying to update this app to allow the use of SQL
Server databases. At one point, we create a TableDef object for one of
the tables, then loop through the fields, looking at the TableDef.Type
with a Case statement and then acting accordingly. The problem is, the
TableDef.Type for SQL Server fields is not the same as for the Access
fields. So, I began debugging the code to get the values, but the
problem is that the Type is inconsistent. Nvarchar fields have a
TableDef.Type of 56 when running the program one time, but other times
have types of 57, 62, 60, etc. Is there a reason these are not
consistent? Is there a range of values that the types fall into? I'm
looking for a resource that shows the TableDef.Type values for SQL
Server field datatypes. Anyone know where I can find this?




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

Default Re: DAO TableDef and SQL Server - 03-06-2006 , 12:35 PM



Unfortunately, this is not an option. I am adding changes to an
existing app, and cannot change to ADO.


Reply With Quote
  #4  
Old   
JT
 
Posts: n/a

Default Re: DAO TableDef and SQL Server - 03-06-2006 , 01:11 PM



Well, loop through the entire table and collect every distinct value of
TableDef.Type that DAO returns for the column, and perhaps it will distill
down to a specific few. Also, if the other data types, such as Int or char,
are consistent, then perhaps code your select.. case.. in such a way that
otherwise is assumed to be nvarchar.

Are you sure it's not the data length that being returned?

"Sean" <nbSean (AT) gmail (DOT) com> wrote

Quote:
I working on an existing app that uses DAO to connect to Access
databases. I am trying to update this app to allow the use of SQL
Server databases. At one point, we create a TableDef object for one of
the tables, then loop through the fields, looking at the TableDef.Type
with a Case statement and then acting accordingly. The problem is, the
TableDef.Type for SQL Server fields is not the same as for the Access
fields. So, I began debugging the code to get the values, but the
problem is that the Type is inconsistent. Nvarchar fields have a
TableDef.Type of 56 when running the program one time, but other times
have types of 57, 62, 60, etc. Is there a reason these are not
consistent? Is there a range of values that the types fall into? I'm
looking for a resource that shows the TableDef.Type values for SQL
Server field datatypes. Anyone know where I can find this?




Reply With Quote
  #5  
Old   
Sean
 
Posts: n/a

Default Re: DAO TableDef and SQL Server - 03-06-2006 , 03:17 PM



Ok, all other types of fields (bit, number, etc.) are consistent, the
text fields (nvarchar, ntext, etc.) are not. So, I took your
suggestion and put the text logic under the Case Else. This seems to
be the only workaround. Thanks for your help.


Reply With Quote
Reply




Thread Tools
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.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.