Inferring parameter type when passing DBNull

Hello,
how can I generate a SqlParameter with DBNull value if I don't know the column type? If I do not specify it, it defaults to string and the command fails if the column type is different.
The SQL server does not seem to worry that much about types if you include NULL in the statement directly, so is there a way how to achieve this using the parameters?
Thanks,
Jan

OK, well I was talking about setting the column value to Null *in* the stored procedure based upon what it has received from .NET. I'm not sure how the parameter type in ADO.NET is relevant in this instance. That is unless we're not
talking about the same thing.
Is there an issue with using optional parameters and defaulting a column value to Null? I don't think ADO.NET is going to be much help here.
Paul ~~~~ Microsoft MVP (Visual Basic)

Similar Messages

  • "Missing parameter values " when passing parameter to subreport

    i have a subreport embedded in main report.
    sub report take a procedure with parameter.the main report does nothing but only holds many sub report.now i have to pass parameter from code to sub report.ive used the following code but it gives "missing parameter values" error
    Any help??
       ParameterField paramField = new ParameterField();
            ParameterFields paramFields = new ParameterFields();
            ParameterDiscreteValue paramDiscreteValue = new ParameterDiscreteValue();
            paramField.Name = "@LabNo";
            paramDiscreteValue.Value = "1034";
            paramFields.Add(paramField);
            ParameterValues paramvalues = new ParameterValues();
           paramvalues.Add(paramDiscreteValue);
            paramField.CurrentValues.Add(paramDiscreteValue);
    rptDocument.ParameterFields[0].CurrentValues = paramvalues;

    does the sub report have parameters in it as well?
    if the sp used for the sub report has parameters you need to pass them to the sub. i would probably remove the parameters from the sub and join the sub to the main by the parameter from the main to the field in the sub.

  • When/How to use - "search" parameter type in parameter like other types.

    We recently upgraded BI Publisher to 10.1.3.4. I saw new parameter type "search" in parameter section, when creating report. whats the use of it? How to use it ? like other parameter type Text, Menu,Hidden, Date.
    I couldn't find any help or release notes on this !
    Thanks
    Ayaps

    I started looking into this parameter type when our drop-down for customer numbers went from 13,000 (manageable) to 45,000 (completely unmanageable).
    I imagine this is supposed to mimic the effects of a "Long List" type LOV in Oracle Applications (as I had inquired about in [this thread|http://forums.oracle.com/forums/thread.jspa?threadID=895521&stqc=true|Large List of Values (LoV) hangs. Is there an equivalent for a long list?]), but performance-wise, "Search" does not seem to be any more efficient that using the "Menu" type LOV. Even with the help of having a partial string with a wildcard to match, the "Search" still takes too long to pull up to be of any use to us.

  • How to use INVOKE function with INT parameter types

    Can you tell me how to use invoke function with int parameter type ?

    Pass the int as an Integer.

  • Parameter type conflict from Toplink 11g when passing ArrayList as input

    When passing ArrayList as an input to a StoredProcedureCall, I am getting the following stacktrace:
    t] Exception [TOPLINK-4002] (Oracle TopLink - 11g Release 1 (11.1.1.0.0) (Build 080121)): oracle.toplink.exceptions.DatabaseException
    [junit] Internal Exception: java.sql.SQLException: Parameter Type Conflict
    [junit] Error Code: 17012
    [junit] Call: BEGIN XL_SP_ASSIGN_EVENTLIST(?, usrName=>?, assignUsrkey=>?, assignGrpkey=>?); END;
    [junit] bind => [null => eventIdList, FOO1, 117, 0]
    [junit] Query: ValueReadQuery()
    [junit] at oracle.toplink.exceptions.DatabaseException.sqlException(DatabaseException.java:295)
    [junit] at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:724)
    [junit] at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedure(DatabasePlatform.java:1627)
    [junit] at oracle.toplink.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:534)
    [junit] at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:467)
    Here is my code snippet to pass ArrayList as input parameter :
    StoredProcedureCall spc = new StoredProcedureCall();
    spc.setProcedureName(procedureName);
    spc.addUnamedInOutputArgument("eventIdList", "eventIdList", Types.ARRAY,
    "EVENTIDS", ArrayList.class);
    String argLoggedInUsrName = "usrName";
    String argAssignedUsrKey = "assignUsrkey";
    String argAssignedGrpKey = "assignGrpkey";
    spc.addNamedArgument(argLoggedInUsrName);
    spc.addNamedArgument(argAssignedUsrKey);
    spc.addNamedArgument(argAssignedGrpKey);
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(spc);
    query.addArgument("eventIdList");
    query.addArgument(argLoggedInUsrName);
    query.addArgument(argAssignedUsrKey);
    query.addArgument(argAssignedGrpKey);
    Vector args = new Vector();
    ArrayList eventIdList = new ArrayList();
    eventIdList.add(new Long(50000));
    args.add(eventIdList);
    args.add(loggedInUsrName);
    args.add(assignedUsrKey);
    args.add(assignedGrpKey);
    eventIdList = (ArrayList) session.executeQuery(query, args);
    This code chunk was working with an earlier build. Would really appreciate any inputs on the error seen.
    Please note - the EVENTIDs type in the pl/sql procedure is defined as a VARRAY(100) of NUMBER

    Well I posted a thread several weeks ago...see this thread below
    trying to get used to sql*plus, running and creating a simple procedure
    and someone made comments about the select query leading to sql injection. Now I am trying to understand the true case behind that. I have an idea made it is because of the first concatenation in the parameter or not. Not sure.

  • My iPod touch is permanently disabled and it says to connect my iPod to my iTunes yet when I do that, it tells me to type in pass code even though it's still disabled. i cant go to DFU mode cause my home button is broken PLEASE HELP ME GOD I MISS MY IPOD

    My iPod touch is permanently disabled and it says to connect my iPod to my iTunes yet when I do that, it tells me to type in pass code even though it's still disabled. i cant go to DFU mode cause my home button is broken PLEASE HELP ME GOD I MISS MY IPOD TOUCH PLEASE :'((

    i cant do that sir ,my ipod touch 4g keeps rebooting and rebooting all over again until the battery is empty HELP GUYS PLEASE

  • My iPod touch is permanently disabled and it says to connect my iPod to my iTunes yet when I do that, it tells me to type in pass code even though it's still disabled. PLEASE HELP ME

    My iPod touch is permanently disabled and it says to connect my iPod to my iTunes yet when I do that, it tells me to type in pass code even though it's still disabled. PLEASE HELP ME

    I have the same problem with mine... but im trying to find a way to fix it without restoring it...
    but one fix is to shut it down completely ... then press and hold BOTH the power button and the home button .. hold both of those 4 ten seconds .. then release the power button but still hold down the home button .. and then it'll show something that says "connect to itunes" once u get it connected to itunes , click the restore button ... BEWARE THIS WILL WIPE OUT EVERYTHING ON YOUR IPOD!!! IT WILL RESTORE IT BACK TO FACTORY SETTINGS , AS IF U JUST BOUGHT IT !!!!! then it should work fine again .. but u will lose all data on there besides the things you have synced with itunes already..
    Thats y im iffy with doing this , im trying to find a fix where i wont have 2 restore it but i dont think there is 1 :'(
    good luck tho
    ~sam

  • Sub Query Error When Passing Dynamic Parameter.

    Dear All, I need help for below query problem.
    I have try below query run no problem when pass a static Parameter into the query but it throw error once i have add in the dynamic parameter:-
    --Sales BatchNum Transaction
    SELECT T0.[ItemCode], T0.[ItemName], T0.[WhsCode], T0.[BatchNum], ISNULL(T4.[AvgPrice],0) AS 'Avg Price', SUM(T0.[Quantity]) AS 'Sales Quantity',
    (SELECT [Quantity] FROM [OIBT] T1 WHERE T1.[ItemCode] = T0.[ItemCode] AND T1.[WhsCode] = T0.[WhsCode] AND T1.[BatchNum]=T0.[BatchNum]) AS 'Stock OnHand'
    FROM [IBT1] T0 INNER JOIN [OITM] T2 ON T0.[ItemCode] = T2.[ItemCode]
                      INNER JOIN [OITB] T3 ON T2.[ItmsGrpCod] = T3.[ItmsGrpCod]
                      INNER JOIN [OITW] T4 ON T0.[ItemCode] = T4.[ItemCode] AND T0.[WhsCode] = T4.[WhsCode]
    WHERE T0.[BaseType] = [%0] AND T0.[DocDate] BETWEEN [%1] AND [%2] AND T3.[ItmsGrpNam] = [%3]
    GROUP BY T0.[ItemCode], T0.[ItemName], T0.[WhsCode], T0.[BatchNum], T4.[AvgPrice]
    --ORDER BY T0.[ItemCode]
    UNION ALL
    --No Sales Batch Transaction
    SELECT T4.[ItemCode], T4.[ItemName],T4.[WhsCode], T4.[BatchNum], ISNULL(T7.[AvgPrice],0) AS 'Avg Price', 0 AS 'Sales Quantity' ,SUM(T4.[Quantity])
    FROM [OIBT] T4 INNER JOIN [OITM] T5 ON T4.[ItemCode] = T5.[ItemCode]
                      INNER JOIN [OITB] T6 ON T5.[ItmsGrpCod] = T6.[ItmsGrpCod]
                      INNER JOIN [OITW] T7 ON T4.[ItemCode] = T7.[ItemCode] AND T4.[WhsCode] = T7.[WhsCode]
    WHERE NOT EXISTS
    ( SELECT T0.[ItemCode], T0.[ItemName], T0.[WhsCode], T0.[BatchNum], ISNULL(T5.[AvgPrice],0) AS 'Avg Price', SUM(T0.[Quantity]) AS 'Sales Quantity'
      FROM [IBT1] T0 INNER JOIN [OITM] T2 ON T0.[ItemCode] = T2.[ItemCode]
                        INNER JOIN [OITB] T3 ON T2.[ItmsGrpCod] = T3.[ItmsGrpCod]
                         INNER JOIN [OITW] T5 ON T0.[ItemCode] = T5.[ItemCode] AND T0.[WhsCode] = T5.[WhsCode]
      WHERE T0.[BaseType] = [%1] AND T0.[DocDate] BETWEEN [%1] AND [%2] AND T4.[ItemCode]=T0.[ItemCode] AND T4.[WhsCode]=T0.[WhsCode] AND T4.[BatchNum]=t0.[BatchNum] AND T3.[ItmsGrpNam] = [%3]
      GROUP BY T0.[ItemCode], T0.[ItemName], T0.[WhsCode], T0.[BatchNum],T5.[AvgPrice]
    AND T6.[ItmsGrpNam] = [%3]
    GROUP BY T4.[ItemCode], T4.[ItemName], T4.[WhsCode], T4.[BatchNum], T7.[AvgPrice]
    HAVING SUM(T4.[Quantity]) > 0
    ORDER BY 1, 2, 3, 5 DESC
    I think SAP Query Manager can support the sub-query, kindly advise how to solve or other alternative way to solve this issue.
    Thanks a lot.

    Dear  Thanga Raj K,
    From your solution i can get my expected result, only within your solution you miss out the @ in line 32 for ToDate variable.
    After i have added it, it working perfectly.
    Thanks once again.
    For other user References code(Corrected):-
    Declare @basetype as int
    Declare @FromDate as Datetime
    Declare @ToDate as Datetime
    Declare @ItemGroup as nvarchar(30)
    set @basetype = (select max(s0.BaseType) from IBT1 S0 where s0.BaseType = '[%0]')
    set @FromDate = (select min(S1.DocDate) from IBT1 S1 where S1.DocDate >= '[%1]')
    set @ToDate = (select max(S2.DocDate) from IBT1 S2 where S2.DocDate <= '[%2]')
    set @ItemGroup = (select max(S3.ItmsGrpNam) from OITB s3 where S3.ItmsGrpNam = '[%3]')
    --Sales BatchNum Transaction
    SELECT T0.ItemCode, T0.ItemName, T0.WhsCode, T0.BatchNum, ISNULL(T4.AvgPrice,0) AS 'Avg Price', SUM(T0.Quantity) AS 'Sales Quantity',
    (SELECT Quantity FROM OIBT T1 WHERE T1.ItemCode = T0.ItemCode AND T1.WhsCode = T0.WhsCode AND T1.BatchNum=T0.BatchNum) AS 'Stock OnHand'
    FROM IBT1 T0 INNER JOIN OITM T2 ON T0.ItemCode = T2.ItemCode
    INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
    INNER JOIN OITW T4 ON T0.ItemCode = T4.ItemCode AND T0.WhsCode = T4.WhsCode
    WHERE T0.BaseType = @basetype AND T0.DocDate BETWEEN @FromDate AND @ToDate AND T3.ItmsGrpNam = @ItemGroup
    GROUP BY T0.ItemCode, T0.ItemName, T0.WhsCode, T0.BatchNum, T4.AvgPrice
    --ORDER BY T0.ItemCode
    UNION ALL
    --No Sales Batch Transaction
    SELECT T4.ItemCode, T4.ItemName,T4.WhsCode, T4.BatchNum, ISNULL(T7.AvgPrice,0) AS 'Avg Price', 0 AS 'Sales Quantity' ,SUM(T4.Quantity)
    FROM OIBT T4 INNER JOIN OITM T5 ON T4.ItemCode = T5.ItemCode
    INNER JOIN OITB T6 ON T5.ItmsGrpCod = T6.ItmsGrpCod
    INNER JOIN OITW T7 ON T4.ItemCode = T7.ItemCode AND T4.WhsCode = T7.WhsCode
    WHERE NOT EXISTS
    (SELECT T0.ItemCode, T0.ItemName, T0.WhsCode, T0.BatchNum, ISNULL(T5.AvgPrice,0) AS 'Avg Price', SUM(T0.Quantity) AS 'Sales Quantity'
    FROM IBT1 T0 INNER JOIN OITM T2 ON T0.ItemCode = T2.ItemCode
    INNER JOIN OITB T3 ON T2.ItmsGrpCod = T3.ItmsGrpCod
    INNER JOIN OITW T5 ON T0.ItemCode = T5.ItemCode AND T0.WhsCode = T5.WhsCode
    WHERE T0.BaseType = @basetype AND T0.DocDate BETWEEN @FromDate AND @ToDate AND T4.ItemCode=T0.ItemCode AND T4.WhsCode=T0.WhsCode AND T4.BatchNum=t0.BatchNum AND T3.ItmsGrpNam = @ItemGroup
    GROUP BY T0.ItemCode, T0.ItemName, T0.WhsCode, T0.BatchNum,T5.AvgPrice
    AND T6.ItmsGrpNam = @ItemGroup
    GROUP BY T4.ItemCode, T4.ItemName, T4.WhsCode, T4.BatchNum, T7.AvgPrice
    HAVING SUM(T4.Quantity) > 0
    ORDER BY 1, 2, 3, 5 DESC

  • How to skip the spaces, ' etc when passing the parameter to srw.run_report?

    Hi, I have got problem with passing parameter to srw.run_report. It seems it doesn't take the special symbols such as space, ', etc.. the statement is like:
    srw.run_report('report=test1 p_name='&#0124; &#0124;:p_title);
    if :p_title is "JOE", there is no problem to pass it, but if the :p_title is "JOE LI", then the value of the parameter can be passed to p_name.
    Does any one know how to skip those special symbols in the string when passing it to srw.run_report. Thank you very much.
    Joe

    Hi,
    Try this :
    srw.run_report('report=test1 p_name='&#0124; &#0124;
    chr(34)&#0124; &#0124;:p_title&#0124; &#0124;chr(34)
    );

  • HT1212 my phone touch system has been destroyed i have to make a backup in laptop but when i m connecting ma device to itunes of ma laptop so its saying your device have a paascode like ma phone touch system is not working how should i type ma pass word ?

    my phone touch system has been destroyed i have to make a backup in laptop but when i m connecting ma device to itunes of ma laptop so its saying your device have a paascode like ma phone touch system is not working how should i type ma pass word ??? is there any way to open ma device from laptop nd sync my data , contacts etc to ma laptop ... i have to make my phone repair then...please help with thiss...

    Sorry No, if your screen is broken, then you won't be able to unlock your phone.
    You do backup your phone on a regular basis right?

  • What type of license should the user be assigned when passing transactions through the DI Server?

    What type of license should the user be assigned when passing transactions through the DI Server?
    We used to assign indirect access licenses to users that were just using the DI Server.  We have one add-on developer that says that the user has to be a Profession license. Current environment is SAP B1 9.0 PL10.  My understanding was that you could have up to 10 users assigned to a single DI Server license.

    Hi,
    From the license guide,
    Indirect Access – has access to any SSP solutions (developed with the SAP Business One DI-API) only. The Indirect Access license is bundled with the DI server. Users who have an Indirect Access license can access a limited number of application forms, but cannot perform any functions with the SAP Business One application. Users who have an Indirect Access license can access an unlimited number of SSP solutions
    Thanks & Regards,
    Nagarajan

  • Generic Method, How parameter type is determined

    For method
    <T> void fromArrayToCollection(T[] a, Collection<T> c) { ... } Why does
    fromArrayToCollection(sa, co);passes and
    fromArrayToCollection(oa, cs); fails.
    oa - Object Array, Object[]
    cs - Collection of String, Collection<String>
    sa - String Array, String[]
    co - Collection of Object, Collection<Object>
    What are the rules governing the type of T inferred by compiler?

    epiphanetic wrote:
    I think you still haven't fully understood the issue.
    I suggest, you also read the same generics tutorial by Gilad Bracha, section 6 from where I found this issue :). Ha! But I think it's misleading that that section uses arrays.
    In his words "It will generally infer the most specific type argument that will make the call type-correct." Its also mentioned that collection parameter type has to be supertype of Array parameter type but no reason is given. I wonder why it fails to infer correct type in second case.Assume you passed in an array of Objects, and a Collection of Strings, and it was possible that T would then be Object. Using Bracha's example implementation:
    static <T> void fromArrayToCollection(T[] a, Collection<T> c) {
       for (T o : a) {
          c.add(o); // correct
    }Now imagine you had this code making use of it:
    Object[] objects = {Integer.valueOf(1), "hi", new Object()};
    Collection<String> strings = new LinkedList<String>();
    fromArrayToCollection(objects, strings);
    String string = strings.iterator().next(); //get first String, which is actually an IntegerTrying to get the first String would give a ClassCastException. So clearly that method cannot not be safely invoked.
    The reason I think he's confusing things by using the array is because you might get it in your head that this would be OK:
    static <T> void fromCollectionToCollection(Collection<T> one, Collection<T> two) {
       for ( T t : one ) {
          two.add(t);
    Collection<Object> col1; Collection<String> col2;
    doSomething(col1, col2);When clearly it's unsafe, as now your Collection of Strings might have a non-String in it! That's why I said this is more a nuance of generic arrays than of type inference proper.

  • IN,OUT and IN OUT Parameter Types

    Dear All,
    as per some book,
    IN parameter uses Call by Reference
    and OUT and IN OUT Uses Call by Value
    we can use NOCOPY for Making OUT and IN OUT Call by Reference.
    my small doubt is
    when u r passing a reference of a Variable how oracle takes care that only IN Parameter are not allowed to change (in c and c++ we can say *para to access the variables) ,
    i mean in case i use NOCOPY all parameter type are using CALL BY REFERENCE then how the "No Modify" is forced in case of IN Parameter.
    Thanks for Reading Request.
    Raj.

    The pl/sql compiler will simply not allow you to have a stmt that assigns something to an "IN" parameter. It can fully be enforced at compile time.
    Tom Best

  • Raw parameter type

    Hi all,
    my WD application call the RFC "CRM_ICSS_UPLOAD_SR_ATTACHMENT" for attach documents. But, the file content parameter is the RAW type. I send the byte[] value for this parameter, but when I try to open the file uploaded in transaction, the file is corrupted (the content doesn't open). I try to pass the file content. For txt files, its OK!, but to images and other files, the file is open, but this content is corrupted!!!
    Any suggestions!?
    Thanks,
    Yuri.

    CHAR is limited to 2k.
    VARCHAR2 is limited to 4k.
    You should be using CLOB if you're
    saving XML strings.

  • Parameter type

    Hi
    I'm do'g an offline interactive pdf form in which i'm using the func.SCMS_XSTRING_TO_BINARY to get the generated pdf and convert into binary format.This func.mod has got a tables para  'binary_tab'.What should be the table of the parameter to be passed to this...becoz in the later stage of prog. its raising an error <b>"LT_ATT_CONTENT_HEX" is not type-compatible with formal parameter     "I_ATT_CONTENT_HEX".</b> when i passed a char field table type to it.
    If i couldn't make it clear to you....Please go through the code snippet below...
    And reply me soon...
    begin of lt_att_content_hex occurs 0,
         binary(200),
         end of lt_att_content_hex.
    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        BUFFER                = formoutput-pdf   "PDF file from function
                                                  "module
    *   APPEND_TO_TABLE       = ' '
    * IMPORTING
    *   OUTPUT_LENGTH         =
      TABLES
        BINARY_TAB            = lt_att_content_hex
    CLASS cl_bcs DEFINITION LOAD.
    DATA:
    lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
    lo_send_request = cl_bcs=>create_persistent( ).
    * Message body and subject
    DATA:
    lt_message_body TYPE bcsy_text VALUE IS INITIAL,
    lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
    APPEND 'Dear Vendor,' TO lt_message_body.
    append ' ' to lt_message_body.
    APPEND 'Please fill the attached form and send it back to us.'
    TO lt_message_body.
    append ' ' to lt_message_body.
    APPEND 'Thank You,' TO lt_message_body.
    lo_document = cl_document_bcs=>create_document(
    i_type = 'RAW'
    i_text = lt_message_body
    i_subject = 'Vendor Payment Form' ).
    DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
    TRY.
    lo_document->add_attachment(
    EXPORTING
    i_attachment_type = 'PDF'
    i_attachment_subject = 'Vendor Payment Form'
    * I_ATTACHMENT_SIZE =
    * I_ATTACHMENT_LANGUAGE = SPACE
    * I_ATT_CONTENT_TEXT =
    * I_ATTACHMENT_HEADER =
    i_att_content_hex = lt_att_content_hex ).

    Hi,
    use
    data: lt_hex_tab     TYPE solix_tab.
    for your binary table
    regards
    Maik

Maybe you are looking for

  • Can i merge users on the same iMac

    i've just got my first mac. I migrated files from old pc. This has created another user. Can I merge the two?

  • My Mac Book Pro does not recognize the presence of a DVD or CD

    Ever since I upgraded my MacBook Pro, it does not recognize a DVD or CD of any type when I put it in. I have a store bought DVD, the Social Network, which worked fine before upgrading to OSX operating system. Music CD's were okay then, too. Now, neit

  • Button opens link in a new window

    Hello everyone, This is a rather simple question for all gurus out there, but it seems a bit hard to find on documentation. How can you open a link in a new window with a button in a flash form? I want a button on my form to pop a new window with a s

  • Stonlen iPod

    My iPod was stolen how do i track it down? is there a way to find out where it is?

  • Photoshop CS6 Video Timeline Pixelated?  Plese Help!!

    All objects and text's look great until I hit the play button, then everything becomes pixelated?  Any thoughts on why?  Please help