Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to convert ADO.rs.field.type to DAO.rs.field.type?

Posted on 2001-06-25
2
364 Views
Last Modified: 2012-06-21
Hi,

I need to create mdb files on the fly with data from SQL server. I'll be getting data through ADODB.rs. When I try to create mdb file using the following syntex:

Set dbDatabase = CreateDatabase(sNewDBPathAndName, dbLangGeneral, dbEncrypt)

For Each fld In rs.Fields
    Set fldArray(i) = tdLogTable.CreateField(fld.Name, fld.Type, fld.DefinedSize)
    i = i + 1
Next

the program error out at the table.CreateField method. The "fld.Type" returns an ADODB.rs.field type which can't be recognized by the CreateField method. Can anyone show me how to solve this? Thanks in advance!
0
Comment
Question by:ahpui
2 Comments
 
LVL 5

Accepted Solution

by:
rkot2000 earned 50 total points
ID: 6224775
i am using the following select case to convert from ado to string. You can do the same :
Function GetDataTypeEnum(lngDataTypeEnum As Long) As String
      'Given ADO data-type constant, returns readable constant name.
      Dim strReturn As String
         Select Case lngDataTypeEnum
            Case 0: strReturn = "adEmpty"
            Case 16: strReturn = "adTinyInt"
            Case 2: strReturn = "adSmallInt"
            Case 3: strReturn = "adInteger"
            Case 20: strReturn = "adBigInt"
            Case 17: strReturn = "adUnsignedTinyInt"
            Case 18: strReturn = "adUnsignedSmallInt"
            Case 19: strReturn = "adUnsignedInt"
            Case 21: strReturn = "adUnsignedBigInt"
            Case 4: strReturn = "adSingle"
            Case 5: strReturn = "adDouble"
            Case 6: strReturn = "adCurrency"
            Case 14: strReturn = "adDecimal"
            Case 131: strReturn = "adNumeric"
            Case 11: strReturn = "adBoolean"
            Case 10: strReturn = "adError"
            Case 132: strReturn = "adUserDefined"
            Case 12: strReturn = "adVariant"
            Case 9: strReturn = "adIDispatch"
            Case 13: strReturn = "adIUnknown"
            Case 72: strReturn = "adGUID"
            Case 7: strReturn = "adDate"
            Case 133: strReturn = "adDBDate"
            Case 134: strReturn = "adDBTime"
            Case 135: strReturn = "adDBTimeStamp"
            Case 8: strReturn = "adBSTR"
            Case 129: strReturn = "adChar"
            Case 200: strReturn = "adVarChar"
            Case 201: strReturn = "adLongVarChar"
            Case 130: strReturn = "adWChar"
            Case 202: strReturn = "adVarWChar"
            Case 203: strReturn = "adLongVarWChar"
            Case 128: strReturn = "adBinary"
            Case 204: strReturn = "adVarBinary"
            Case 205: strReturn = "adLongVarBinary"
         Case Else:
            strReturn = "Unknown"
          End Select
         GetDataTypeEnum = strReturn
      End Function
0
 

Author Comment

by:ahpui
ID: 6229356
Thanks! It works after a minor modification.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question