Array of obj

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl

    #1

    Array of obj

    Hi, I want to pass an array of object of different type
    to a function and use it in the function.

    I am not able to have it working.

    Function that create the array...

    public virtual DataSet GetFacturesClie ntListeDS(strin g
    client)
    {
    Object[] parametre = new object[4]
    {"client",OleDb Type.Char,60,cl ient};

    string select = "SELECT distinct
    details.d_nfact ure,project.p_n ame FROM project,details
    where project.p_clien t = ? and project.p_refno =
    details.d_refno and !empty(details. d_nfacture) ORDER BY
    d_nfacture";

    DataSet myDS = SqlGenericDataS et
    (select,"client ","SQLPME","AUC UNE",parametre) ;
    return myDS;
    }

    Function to use the array,

    public DataSet SqlGenericDataS et(string sqlquery,string
    tablename,strin g ConfigConnectio nKey, string fonction,
    Object[] aParameter)
    {
    SqlConnection GenericConnecti on = new
    System.Data.Sql Client.SqlConne ction
    (ConfigurationS ettings.AppSett ings[ConfigConnectio nKey]);
    SqlCommand GenericCommand = new
    System.Data.Sql Client.SqlComma nd(sqlquery,
    GenericConnecti on);

    for (int a = 1;a<=aParameter .GetLength(0);a ++)
    {
    GenericCommand. Parameters.Add( (string)aParame ter.GetValue
    (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
    aParameter.GetV alue(a,2));

    GenericCommand. Parameters[(string)aParame ter.GetValue
    (a,0)].Value = (string)aParame ter.GetValue(a, 3);
    }


    Any idea's??

    Carl


  • Jeffrey Tan[MSFT]

    #2
    RE: Array of obj


    Hi Carl,

    Where is the problem that the code does not work?
    What is your code snippet's function?
    However, I found that your aParameter shoud be 2-dimension array.
    And your GenericConnecti on should be opened after construct.

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.

    --------------------
    | Content-Class: urn:content-classes:message
    | From: "Carl" <Carl@cb-cinc.com>
    | Sender: "Carl" <Carl@cb-cinc.com>
    | Subject: Array of obj
    | Date: Mon, 25 Aug 2003 19:23:53 -0700
    | Lines: 53
    | Message-ID: <075101c36b79$1 83383f0$a401280 a@phx.gbl>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="iso-8859-1"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    | Thread-Index: AcNreRgzgUdYKA3 HSZSLulpbpF1Jow ==
    | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    | Path: cpmsftngxa06.ph x.gbl
    | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1793 02
    | NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
    |
    | Hi, I want to pass an array of object of different type
    | to a function and use it in the function.
    |
    | I am not able to have it working.
    |
    | Function that create the array...
    |
    | public virtual DataSet GetFacturesClie ntListeDS(strin g
    | client)
    | {
    | Object[] parametre = new object[4]
    | {"client",OleDb Type.Char,60,cl ient};
    |
    | string select = "SELECT distinct
    | details.d_nfact ure,project.p_n ame FROM project,details
    | where project.p_clien t = ? and project.p_refno =
    | details.d_refno and !empty(details. d_nfacture) ORDER BY
    | d_nfacture";
    |
    | DataSet myDS = SqlGenericDataS et
    | (select,"client ","SQLPME","AUC UNE",parametre) ;
    | return myDS;
    | }
    |
    | Function to use the array,
    |
    | public DataSet SqlGenericDataS et(string sqlquery,string
    | tablename,strin g ConfigConnectio nKey, string fonction,
    | Object[] aParameter)
    | {
    | SqlConnection GenericConnecti on = new
    | System.Data.Sql Client.SqlConne ction
    | (ConfigurationS ettings.AppSett ings[ConfigConnectio nKey]);
    | SqlCommand GenericCommand = new
    | System.Data.Sql Client.SqlComma nd(sqlquery,
    | GenericConnecti on);
    |
    | for (int a = 1;a<=aParameter .GetLength(0);a ++)
    | {
    | GenericCommand. Parameters.Add( (string)aParame ter.GetValue
    | (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
    | aParameter.GetV alue(a,2));
    |
    | GenericCommand. Parameters[(string)aParame ter.GetValue
    | (a,0)].Value = (string)aParame ter.GetValue(a, 3);
    | }
    |
    |
    | Any idea's??
    |
    | Carl
    |
    |
    |

    Comment

    • Carl

      #3
      RE: Array of obj

      My trouble is with the array ,how do you iterate trough
      it, my syntax is probably not ok.

      The line giving me the error in the previous post is

      GenericCommand. Parameters.Add( (string)aParame ter.GetValue
      (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
      aParameter.GetV alue(a,2));


      This is the message I receive,

      An unhandled exception of
      type 'System.Web.Ser vices.Protocols .SoapException'
      occurred in system.web.serv ices.dll

      Additional information:
      System.Web.Serv ices.Protocols. SoapException: Server was
      unable to process request. ---> System.Argument Exception:
      Array was not a two-dimensional array.
      at System.Array.Ge tValue(Int32 index1, Int32 index2)
      at WS_PME.DB.SqlGe nericDataSet(St ring sqlquery, String
      tablename, String ConfigConnectio nKey, String fonction,
      Object[] aParameter) in f:\structure\pr ojets\vs2003
      \pme\ws_pme\com ponents\db_data set.cs:line 92
      at WS_PME.DB.GetFa cturesClientLis teDS(String client)
      in f:\structure\pr ojets\vs2003
      \pme\ws_pme\com ponents\db_data set.cs:line 125
      at WS_PME.WSPME.Fa cturesClientLis teDS(String client)
      in f:\structure\pr ojets\vs2003
      \pme\ws_pme\pme .asmx.cs:line 63
      --- End of inner exception stack trace ---
      [color=blue]
      >-----Original Message-----
      >
      >Hi Carl,
      >
      >Where is the problem that the code does not work?
      >What is your code snippet's function?
      >However, I found that your aParameter shoud be 2-[/color]
      dimension array.[color=blue]
      >And your GenericConnecti on should be opened after[/color]
      construct.[color=blue]
      >
      >Best regards,
      >Jeffrey Tan
      >Microsoft Online Partner Support
      >Get Secure! - www.microsoft.com/security
      >This posting is provided "as is" with no warranties and[/color]
      confers no rights.[color=blue]
      >
      >--------------------
      >| Content-Class: urn:content-classes:message
      >| From: "Carl" <Carl@cb-cinc.com>
      >| Sender: "Carl" <Carl@cb-cinc.com>
      >| Subject: Array of obj
      >| Date: Mon, 25 Aug 2003 19:23:53 -0700
      >| Lines: 53
      >| Message-ID: <075101c36b79$1 83383f0$a401280 a@phx.gbl>
      >| MIME-Version: 1.0
      >| Content-Type: text/plain;
      >| charset="iso-8859-1"
      >| Content-Transfer-Encoding: 7bit
      >| X-Newsreader: Microsoft CDO for Windows 2000
      >| X-MimeOLE: Produced By Microsoft MimeOLE[/color]
      V5.50.4910.0300[color=blue]
      >| Thread-Index: AcNreRgzgUdYKA3 HSZSLulpbpF1Jow ==
      >| Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
      >| Path: cpmsftngxa06.ph x.gbl
      >| Xref: cpmsftngxa06.ph x.gbl[/color]
      microsoft.publi c.dotnet.langua ges.csharp:1793 02[color=blue]
      >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
      >| X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
      >|
      >| Hi, I want to pass an array of object of different[/color]
      type[color=blue]
      >| to a function and use it in the function.
      >|
      >| I am not able to have it working.
      >|
      >| Function that create the array...
      >|
      >| public virtual DataSet GetFacturesClie ntListeDS(strin g
      >| client)
      >| {
      >| Object[] parametre = new object[4]
      >| {"client",OleDb Type.Char,60,cl ient};
      >|
      >| string select = "SELECT distinct
      >| details.d_nfact ure,project.p_n ame FROM project,details
      >| where project.p_clien t = ? and project.p_refno =
      >| details.d_refno and !empty(details. d_nfacture) ORDER[/color]
      BY[color=blue]
      >| d_nfacture";
      >|
      >| DataSet myDS = SqlGenericDataS et
      >| (select,"client ","SQLPME","AUC UNE",parametre) ;
      >| return myDS;
      >| }
      >|
      >| Function to use the array,
      >|
      >| public DataSet SqlGenericDataS et(string[/color]
      sqlquery,string[color=blue]
      >| tablename,strin g ConfigConnectio nKey, string fonction,
      >| Object[] aParameter)
      >| {
      >| SqlConnection GenericConnecti on = new
      >| System.Data.Sql Client.SqlConne ction
      >| (ConfigurationS ettings.AppSett ings[/color]
      [ConfigConnectio nKey]);[color=blue]
      >| SqlCommand GenericCommand = new
      >| System.Data.Sql Client.SqlComma nd(sqlquery,
      >| GenericConnecti on);
      >|
      >| for (int a = 1;a<=aParameter .GetLength(0);a ++)
      >| {
      >| GenericCommand. Parameters.Add( (string)[/color]
      aParameter.GetV alue[color=blue]
      >| (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
      >| aParameter.GetV alue(a,2));
      >|
      >| GenericCommand. Parameters[(string)aParame ter.GetValue
      >| (a,0)].Value = (string)aParame ter.GetValue(a, 3);
      >| }
      >|
      >|
      >| Any idea's??
      >|
      >| Carl
      >|
      >|
      >|
      >
      >.
      >[/color]

      Comment

      • Carl

        #4
        RE: Array of obj

        Simplify story.

        I want to have one obj array of 4 columns to pass my
        parameters for SQL when required, could have multiple
        rows or just one.

        Columns 1 = string
        Columns 2 = OleDbType.Char
        Columns 3 = int
        Columns 4 = string

        Here is my declaration, client is a string variable.

        Object[,,,] parametre = new object[4]
        {"client",OleDb Type.Char,60,cl ient};

        Here is the errors when compiling,

        F:\Structure\Pr ojets\VS2003
        \PME\WS_PME\Com ponents\DB_data set.cs(122): Cannot
        implicitly convert type 'object[]' to 'object[*,*,*,*]'

        Now if this was working, on another function I want to
        use does value inside the array. How do you access them,
        I try a lot of ways but nothing is working so far.

        Here is how I try to access it the last time,

        public DataSet SqlGenericDataS et(string sqlquery,string
        tablename,strin g ConfigConnectio nKey, string fonction,
        Object[,,,] aParameter)

        for (int a = 0;a<=aParameter .GetLength(0);a ++)
        {
        GenericCommand. Parameters.Add( (string)aParame ter.GetValue
        (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
        aParameter.GetV alue(a,2));

        GenericCommand. Parameters[(string)aParame ter.GetValue
        (a,0)].Value = (string)aParame ter.GetValue(a, 3);
        }

        Seam simple to do, but....

        Carl,


        Comment

        • Jeffrey Tan[MSFT]

          #5
          RE: Array of obj


          Hi Carl,

          As you can see in the error message, the object array should be 2 dimension.
          I changed your code like this:
          public virtual DataSet GetFacturesClie ntListeDS(strin g job_id)
          {
          Object[,] parametre = new object[,]
          {{"job_id",OleD bType.SmallInt, 60,job_id}}; //use 2-dimension array
          string select = "SELECT * from jobs";
          DataSet myDS =
          SqlGenericDataS et(select,"clie nt","SQLPME","A UCUNE",parametr e);
          return myDS;
          }

          public DataSet SqlGenericDataS et(string sqlquery,string tablename,strin g
          ConfigConnectio nKey, string fonction, Object[,] aParameter)
          {
          try
          {
          SqlConnection GenericConnecti on = new
          System.Data.Sql Client.SqlConne ction("server=l ocalhost;databa se=pubs;uid=sa; p
          wd=");
          GenericConnecti on.Open(); //open the connection
          SqlCommand GenericCommand = new
          System.Data.Sql Client.SqlComma nd(sqlquery,Gen ericConnection) ;

          for (int a = 0;a<aParameter. GetLength(0);a+ +)
          {

          GenericCommand. Parameters.Add( (string)aParame ter.GetValue(a, 0),(SqlDbType)a P
          arameter.GetVal ue(a,1),(int)aP arameter.GetVal ue(a,2));
          GenericCommand. Parameters[(string)aParame ter.GetValue(a, 0)].Value =
          (string)aParame ter.GetValue(a, 3);
          }
          }
          catch(Exception e)
          {
          Console.WriteLi ne (e.Message );
          }
          return new DataSet ();
          }

          I use my default sql server database on my machine and i only create a row
          of object array.

          I make some small changes to your code:
          1. object array changed to 2 dimension
          2. add open method to GenericConnecti on
          3.in the for loop, change a<=aParameter.G etLength(0) to
          a<aParameter.Ge tLength(0)

          It works well on my machine.

          Hope this helps.

          Best regards,
          Jeffrey Tan
          Microsoft Online Partner Support
          Get Secure! - www.microsoft.com/security
          This posting is provided "as is" with no warranties and confers no rights.

          --------------------
          | Content-Class: urn:content-classes:message
          | From: "Carl" <carl@cb-cinc.com>
          | Sender: "Carl" <carl@cb-cinc.com>
          | References: <075101c36b79$1 83383f0$a401280 a@phx.gbl>
          <bRQkRv5aDHA.26 12@cpmsftngxa06 .phx.gbl>
          <0dc801c36be6$d 919e970$a601280 a@phx.gbl>
          | Subject: RE: Array of obj
          | Date: Tue, 26 Aug 2003 09:47:11 -0700
          | Lines: 47
          | Message-ID: <0f4901c36bf1$b 1f946a0$a501280 a@phx.gbl>
          | MIME-Version: 1.0
          | Content-Type: text/plain;
          | charset="iso-8859-1"
          | Content-Transfer-Encoding: 7bit
          | X-Newsreader: Microsoft CDO for Windows 2000
          | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
          | Thread-Index: AcNr8bH5J5D2F7Y VSNiRHck/QpyBcQ==
          | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
          | Path: cpmsftngxa06.ph x.gbl
          | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1795 52
          | NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
          | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
          |
          | Simplify story.
          |
          | I want to have one obj array of 4 columns to pass my
          | parameters for SQL when required, could have multiple
          | rows or just one.
          |
          | Columns 1 = string
          | Columns 2 = OleDbType.Char
          | Columns 3 = int
          | Columns 4 = string
          |
          | Here is my declaration, client is a string variable.
          |
          | Object[,,,] parametre = new object[4]
          | {"client",OleDb Type.Char,60,cl ient};
          |
          | Here is the errors when compiling,
          |
          | F:\Structure\Pr ojets\VS2003
          | \PME\WS_PME\Com ponents\DB_data set.cs(122): Cannot
          | implicitly convert type 'object[]' to 'object[*,*,*,*]'
          |
          | Now if this was working, on another function I want to
          | use does value inside the array. How do you access them,
          | I try a lot of ways but nothing is working so far.
          |
          | Here is how I try to access it the last time,
          |
          | public DataSet SqlGenericDataS et(string sqlquery,string
          | tablename,strin g ConfigConnectio nKey, string fonction,
          | Object[,,,] aParameter)
          |
          | for (int a = 0;a<=aParameter .GetLength(0);a ++)
          | {
          | GenericCommand. Parameters.Add( (string)aParame ter.GetValue
          | (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
          | aParameter.GetV alue(a,2));
          |
          | GenericCommand. Parameters[(string)aParame ter.GetValue
          | (a,0)].Value = (string)aParame ter.GetValue(a, 3);
          | }
          |
          | Seam simple to do, but....
          |
          | Carl,
          |
          |
          |

          Comment

          • Carl

            #6
            RE: Array of obj

            Hi Jeffrey,

            Thanks for the answers I get a little further, I also
            notice another mistake from my part, the OleDbType should
            also be SqlDbType for SQL.

            Right now I do have the following errors reported,

            -------------------------------
            An unhandled exception of
            type 'System.Web.Ser vices.Protocols .SoapException'
            occurred in system.web.serv ices.dll

            Additional information:
            System.Web.Serv ices.Protocols. SoapException: Server was
            unable to process request. --->
            System.Data.Sql Client.SqlExcep tion: Line 1: Incorrect
            syntax near 'client'.
            at System.Data.Sql Client.SqlComma nd.ExecuteReade r
            (CommandBehavio r cmdBehavior, RunBehavior runBehavior,
            Boolean returnStream)
            at System.Data.Sql Client.SqlComma nd.ExecuteReade r
            (CommandBehavio r behavior)
            at
            System.Data.Sql Client.SqlComma nd.System.Data. IDbCommand.Ex
            ecuteReader(Com mandBehavior behavior)
            at System.Data.Com mon.DbDataAdapt er.FillFromComm and
            (Object data, Int32 startRecord, Int32 maxRecords, String
            srcTable, IDbCommand command, CommandBehavior behavior)
            at System.Data.Com mon.DbDataAdapt er.Fill(DataSet
            dataSet, Int32 startRecord, Int32 maxRecords, String
            srcTable, IDbCommand command, CommandBehavior behavior)
            at System.Data.Com mon.DbDataAdapt er.Fill(DataSet
            dataSet, String srcTable)
            at WS_PME.DB.SqlGe nericDataSet(St ring sqlquery, String
            tablename, String ConfigConnectio nKey, String fonction,
            Object[,] aParameter) in f:\structure\pr ojets\vs2003
            \pme\ws_pme\com ponents\db_data set.cs:line 101
            at WS_PME.DB.GetFa cturesClientLis teDS(String clientID)
            in f:\structure\pr ojets\vs2003
            \pme\ws_pme\com ponents\db_data set.cs:line 125
            at WS_PME.WSPME.Fa cturesClientLis teDS(String client)
            in f:\structure\pr ojets\vs2003
            \pme\ws_pme\pme .asmx.cs:line 63
            --- End of inner exception stack trace ---
            ------------------------------------

            From the function SqlGenericDataS et, in line
            GenericDA.Fill( GenericDS, tablename);
            -------------------------------------

            public DataSet SqlGenericDataS et(string sqlquery,string
            tablename,strin g ConfigConnectio nKey, string fonction,
            Object[,] aParameter)
            {
            SqlConnection GenericConnecti on = new
            System.Data.Sql Client.SqlConne ction
            (ConfigurationS ettings.AppSett ings[ConfigConnectio nKey]);
            GenericConnecti on.Open();
            SqlCommand GenericCommand = new
            System.Data.Sql Client.SqlComma nd(sqlquery,
            GenericConnecti on);

            for (int a = 0;a<aParameter. GetLength(0);a+ +)
            {
            GenericCommand. Parameters.Add( (string)aParame ter.GetValue
            (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
            aParameter.GetV alue(a,2));
            GenericCommand. Parameters[(string)aParame ter.GetValue
            (a,0)].Value = (string)aParame ter.GetValue(a, 3);
            }

            GenericCommand. CommandTimeout = 30;
            SqlDataAdapter GenericDA = new SqlDataAdapter( );
            GenericDA.Selec tCommand = GenericCommand;
            DataSet GenericDS = new DataSet();
            GenericDA.Fill( GenericDS, tablename);
            GenericConnecti on.Close();
            return GenericDS;
            }
            -----------------------------------------------

            Here is the function calling SqlGenericDataS et.
            ------------------------------------------------
            public virtual DataSet GetFacturesClie ntListeDS
            (string clientID)
            {
            Object[,] parametre = new object
            [,] {{"client",SqlD bType.Char,60,c lientID}}; //use 2-
            dimension array
            string select = "SELECT distinct
            details.d_nfact ure,project.p_n ame FROM project,details
            where project.p_clien t = ? and project.p_refno =
            details.d_refno and !empty(details. d_nfacture) ORDER BY
            d_nfacture";
            DataSet myDS = SqlGenericDataS et
            (select,"client ","SQLPME","AUC UNE",parametre) ;
            return myDS;
            ------------------------------------------

            This error message occurs in the Reference.cs of the web
            service, at the following line,
            -------------------------------------------
            object[] results = this.Invoke
            ("FacturesClien tListeDS", new object[] {
            client});
            --------------------------------------------
            from the following function,
            --------------------------------------------
            [System.Web.Serv ices.Protocols. SoapDocumentMet hodAttribute
            ("http://tempuri.org/FacturesClientL isteDS",
            RequestNamespac e="http://tempuri.org/",
            ResponseNamespa ce="http://tempuri.org/",
            Use=System.Web. Services.Descri ption.SoapBindi ngUse.Literal
            ,
            ParameterStyle= System.Web.Serv ices.Protocols. SoapParameter
            Style.Wrapped)]
            public System.Data.Dat aSet FacturesClientL isteDS
            (string client) {
            object[] results = this.Invoke
            ("FacturesClien tListeDS", new object[] {
            client});
            return ((System.Data.D ataSet)(results[0]));
            }
            -------------------------------------------------------

            I can see that the variable client contains the good
            string value from the debugger.


            Again, thanks for your time....

            Carl,

            Comment

            • Jeffrey Tan[MSFT]

              #7
              RE: Array of obj


              Hi Carl,

              I think you should post your article in this newsgroup:
              microsoft.publi c.dotnet.framew ork.aspnet
              In there, our engineer will help you indeep.

              Best regards,
              Jeffrey Tan
              Microsoft Online Partner Support
              Get Secure! - www.microsoft.com/security
              This posting is provided "as is" with no warranties and confers no rights.

              --------------------
              | Content-Class: urn:content-classes:message
              | From: "Carl" <Carl@cb-cinc.com>
              | Sender: "Carl" <Carl@cb-cinc.com>
              | References: <075101c36b79$1 83383f0$a401280 a@phx.gbl>
              <bRQkRv5aDHA.26 12@cpmsftngxa06 .phx.gbl>
              <0dc801c36be6$d 919e970$a601280 a@phx.gbl>
              <0f4901c36bf1$b 1f946a0$a501280 a@phx.gbl>
              <oEglbSHbDHA.21 84@cpmsftngxa06 .phx.gbl>
              | Subject: RE: Array of obj
              | Date: Wed, 27 Aug 2003 09:14:53 -0700
              | Lines: 134
              | Message-ID: <098f01c36cb6$5 9394900$a001280 a@phx.gbl>
              | MIME-Version: 1.0
              | Content-Type: text/plain;
              | charset="iso-8859-1"
              | Content-Transfer-Encoding: 7bit
              | X-Newsreader: Microsoft CDO for Windows 2000
              | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
              | Thread-Index: AcNstlk5Cc/ZX/tjRSy8zlBKCXixm Q==
              | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
              | Path: cpmsftngxa06.ph x.gbl
              | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1798 90
              | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
              | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
              |
              | Hi Jeffrey,
              |
              | Thanks for the answers I get a little further, I also
              | notice another mistake from my part, the OleDbType should
              | also be SqlDbType for SQL.
              |
              | Right now I do have the following errors reported,
              |
              | -------------------------------
              | An unhandled exception of
              | type 'System.Web.Ser vices.Protocols .SoapException'
              | occurred in system.web.serv ices.dll
              |
              | Additional information:
              | System.Web.Serv ices.Protocols. SoapException: Server was
              | unable to process request. --->
              | System.Data.Sql Client.SqlExcep tion: Line 1: Incorrect
              | syntax near 'client'.
              | at System.Data.Sql Client.SqlComma nd.ExecuteReade r
              | (CommandBehavio r cmdBehavior, RunBehavior runBehavior,
              | Boolean returnStream)
              | at System.Data.Sql Client.SqlComma nd.ExecuteReade r
              | (CommandBehavio r behavior)
              | at
              | System.Data.Sql Client.SqlComma nd.System.Data. IDbCommand.Ex
              | ecuteReader(Com mandBehavior behavior)
              | at System.Data.Com mon.DbDataAdapt er.FillFromComm and
              | (Object data, Int32 startRecord, Int32 maxRecords, String
              | srcTable, IDbCommand command, CommandBehavior behavior)
              | at System.Data.Com mon.DbDataAdapt er.Fill(DataSet
              | dataSet, Int32 startRecord, Int32 maxRecords, String
              | srcTable, IDbCommand command, CommandBehavior behavior)
              | at System.Data.Com mon.DbDataAdapt er.Fill(DataSet
              | dataSet, String srcTable)
              | at WS_PME.DB.SqlGe nericDataSet(St ring sqlquery, String
              | tablename, String ConfigConnectio nKey, String fonction,
              | Object[,] aParameter) in f:\structure\pr ojets\vs2003
              | \pme\ws_pme\com ponents\db_data set.cs:line 101
              | at WS_PME.DB.GetFa cturesClientLis teDS(String clientID)
              | in f:\structure\pr ojets\vs2003
              | \pme\ws_pme\com ponents\db_data set.cs:line 125
              | at WS_PME.WSPME.Fa cturesClientLis teDS(String client)
              | in f:\structure\pr ojets\vs2003
              | \pme\ws_pme\pme .asmx.cs:line 63
              | --- End of inner exception stack trace ---
              | ------------------------------------
              |
              | From the function SqlGenericDataS et, in line
              | GenericDA.Fill( GenericDS, tablename);
              | -------------------------------------
              |
              | public DataSet SqlGenericDataS et(string sqlquery,string
              | tablename,strin g ConfigConnectio nKey, string fonction,
              | Object[,] aParameter)
              | {
              | SqlConnection GenericConnecti on = new
              | System.Data.Sql Client.SqlConne ction
              | (ConfigurationS ettings.AppSett ings[ConfigConnectio nKey]);
              | GenericConnecti on.Open();
              | SqlCommand GenericCommand = new
              | System.Data.Sql Client.SqlComma nd(sqlquery,
              | GenericConnecti on);
              |
              | for (int a = 0;a<aParameter. GetLength(0);a+ +)
              | {
              | GenericCommand. Parameters.Add( (string)aParame ter.GetValue
              | (a,0),(SqlDbTyp e)aParameter.Ge tValue(a,1),(in t)
              | aParameter.GetV alue(a,2));
              | GenericCommand. Parameters[(string)aParame ter.GetValue
              | (a,0)].Value = (string)aParame ter.GetValue(a, 3);
              | }
              |
              | GenericCommand. CommandTimeout = 30;
              | SqlDataAdapter GenericDA = new SqlDataAdapter( );
              | GenericDA.Selec tCommand = GenericCommand;
              | DataSet GenericDS = new DataSet();
              | GenericDA.Fill( GenericDS, tablename);
              | GenericConnecti on.Close();
              | return GenericDS;
              | }
              | -----------------------------------------------
              |
              | Here is the function calling SqlGenericDataS et.
              | ------------------------------------------------
              | public virtual DataSet GetFacturesClie ntListeDS
              | (string clientID)
              | {
              | Object[,] parametre = new object
              | [,] {{"client",SqlD bType.Char,60,c lientID}}; //use 2-
              | dimension array
              | string select = "SELECT distinct
              | details.d_nfact ure,project.p_n ame FROM project,details
              | where project.p_clien t = ? and project.p_refno =
              | details.d_refno and !empty(details. d_nfacture) ORDER BY
              | d_nfacture";
              | DataSet myDS = SqlGenericDataS et
              | (select,"client ","SQLPME","AUC UNE",parametre) ;
              | return myDS;
              | ------------------------------------------
              |
              | This error message occurs in the Reference.cs of the web
              | service, at the following line,
              | -------------------------------------------
              | object[] results = this.Invoke
              | ("FacturesClien tListeDS", new object[] {
              | client});
              | --------------------------------------------
              | from the following function,
              | --------------------------------------------
              | [System.Web.Serv ices.Protocols. SoapDocumentMet hodAttribute
              | ("http://tempuri.org/FacturesClientL isteDS",
              | RequestNamespac e="http://tempuri.org/",
              | ResponseNamespa ce="http://tempuri.org/",
              | Use=System.Web. Services.Descri ption.SoapBindi ngUse.Literal
              | ,
              | ParameterStyle= System.Web.Serv ices.Protocols. SoapParameter
              | Style.Wrapped)]
              | public System.Data.Dat aSet FacturesClientL isteDS
              | (string client) {
              | object[] results = this.Invoke
              | ("FacturesClien tListeDS", new object[] {
              | client});
              | return ((System.Data.D ataSet)(results[0]));
              | }
              | -------------------------------------------------------
              |
              | I can see that the variable client contains the good
              | string value from the debugger.
              |
              |
              | Again, thanks for your time....
              |
              | Carl,
              |
              |

              Comment

              Working...