CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13

Threaded View

  1. #1
    Join Date
    Aug 2014
    Posts
    13

    Question how to dynamically set the CRecordset Fieldtype ?

    Hi
    the problem i am having is that when i try to get
    Code:
     short nFields = rs.GetODBCFieldCount();
    			 CDBVariant b= new CDBVariant[nFields];
    			 for (short index = 0; index < nFields; index++)
    			 {
    				 rs.GetFieldValue(index, b[index],DEFAULT_FIELD_TYPE);		
    			 }
    now i want to change the DEFAULT_FIELD_TYPE dynamically
    so i fount out that using
    CODBCFieldInfo c;
    rs.GetODBCFieldInfo(index, c);
    SQL_C_CHAR h = c.m_nSQLType; //this is not correct but i need a SQL_C_CHAR to pass in rs.GetFieldValue(,,here);

    so how i can dynamically pass the nFieldType becuase if i dont the GetFieldValue get the value in binary which is not correct

    the data i am getting is in this form
    1 jack 23 2015-12-13
    2 ryan 23 2015-12-13
    3 jhon 23 2015-12-13
    so the GetFieldValue (,,nFieldType ) should change but its not changing
    i get the first field ok mean i get the 1 correctly but the name is in binary and other 2 values also in binary

    nFieldType SQL_C_CHAR table is link below
    https://msdn.microsoft.com/en-us/library/5f8k59f9.aspx

    if i go manually then
    for first row

    Code:
    CDBVariant id;
    CDBVariant name;
    CDBVariant age;
    CDBVariant date;
     rs.GetFieldValue(short(0), id,      SQL_C_SLONG);
     rs.GetFieldValue(short(1), name, SQL_C_CHAR);
     rs.GetFieldValue(short(2), age,    SQL_C_SLONG);
     rs.GetFieldValue(short(3), date,   SQL_C_TIMESTAMP);
    but i want to change rs.GetFieldValue(short(0), id,SQL_C_SLONG); this dynamically
    Last edited by tjnapster555; December 16th, 2015 at 03:27 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured