none
loading ::Variant when source type is unknown RRS feed

  • Question

  •  

    Deep in the bowels of an extended stored procedure I am attempting to write a piece of data into the sql record.

    All seems well except that the data to be written is referenced by a char* as a pointer to a block of data.

    The data could be a byte, a word, an integer, a long, a float, a string of ascii characters and so on.

    It seems the SQL datatype syntax has a datatype Variant for such a purpose.

    Problem is at this point, all I have is a pointer to a block of memory, don't really know what data type it is.  I could pass in the length of the source block.

    Can I load the Variant type parameter not knowing what the source datatype is?

     

    /Boyd

     

    ===================

    static void vciWriteTheData( String PtType, String^acPointName, String^acVECName,

    String^ FieldName, char *aclDataBuf)

    {

    SqlConnection ^conn = gcnew SqlConnection("context connection=true");

    SqlCommand ^vciSqlCommand = gcnew SqlCommand();

    SqlParameter ^data_Param = gcnew SqlParameter( "@data_Param" , SqlDbType::Variant);

    data_Param->Value = ??????????????????????????????????????????

     

    vciSqlCommand->CommandText =

    "update "+ PtType + "set " +FieldName +" = @data_Param ", " where VEC = ", acVECName," and name = ",acPointName;

    conn->Open();

    vciSqlCommand->ExecuteNonQuery();

    conn->Close();

    }

    Wednesday, June 27, 2007 7:52 PM