Solved

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

Posted on 2001-06-25
2
367 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

763 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