how to pass a VARIANT data to SQL Server ?

when passing data to server, many data-types require explicitly set the dwxxxLength field, do VARIANT requires and how can i set it's length as it's variant


Answer this question

how to pass a VARIANT data to SQL Server ?

  • RUSSO

    what if i store BSTR in my VARIANT variable

    can your code works as well



  • Aaron R

    If you need to pass different types in one parameter the you could pass it as an XML string, but you would need to use explicit types inside of SP anyway. See next KB about how to pass XML

    http://support.microsoft.com/kb/555266/en-us



  • PreFishing

    What do you need to accomplish

  • Tim Tharratt

    Yes, in OLEDB binding structure:

    Binding.cbMaxLen = sizeof(VARIANT);

    Binding.wType = DBTYPE_VARIANT;

    HTH.



  • wheelersctt

    well, i think you misunderstood!

    i mean i have a col1 which data type is NUMERIC, and col2 which data type is SMALLDATETIME, and in my app, i convert both into variant. now how can i pass a value back to the server, i dont know how to set the dw***Length field



  • Rick0124

    the data store in server is NUMERIC(4,1) and SMALLDATETIME, for convenience, i convert it to VARIANT in my app. my problem is how to pass it back to the server

    can i simply use m_dwxxxLength = sizeof(VARIANT)



  • how to pass a VARIANT data to SQL Server ?