Error in SqlHelper method - vs2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Umljaw==?=

    Error in SqlHelper method - vs2005

    Line #2 in the following code generates an error; what am I doing wrong?

    Error 1 The best overloaded method match for
    'Microsoft.Appl icationBlocks.D ata.SqlHelper.E xecuteDataset(s tring,
    System.Data.Com mandType, string)' has some invalid arguments

    Code:

    Line #1 System.Data.Dat aSet dsCust = new System.Data.Dat aSet();
    Line #2 dsCust = SqlHelper.Execu teReader(sqlCon nection,
    CommandType.Tex t, "SELECT * FROM Customer");
  • Peter Duniho

    #2
    Re: Error in SqlHelper method - vs2005

    On Fri, 31 Oct 2008 15:08:01 -0700, Rick <Rick@discussio ns.microsoft.co m>
    wrote:
    Line #2 in the following code generates an error; what am I doing wrong?
    >
    Error 1 The best overloaded method match for
    'Microsoft.Appl icationBlocks.D ata.SqlHelper.E xecuteDataset(s tring,
    System.Data.Com mandType, string)' has some invalid arguments
    As the error message is so clearly telling you, you are passing a
    parameter of the incorrect type.

    Based on the error and the code you posted, it could be either the
    variable "sqlConnect ion" (it should be a string, but you might be using
    something else), or the CommandType enumeration (there are at least two
    different CommandType types in .NET, and you might be using the wrong
    one), or both.

    Since you posted so little code, it's not possible to tell you
    specifically what's wrong. Maybe the above will be enough for you to
    figure it out yourself.

    For future reference, you should always post a concise-but-complete code
    example that reliably demonstrates your problem. Otherwise, at best you
    make other people guess, and at worst, you run the risk of wasting other
    people's time or just having them ignore your question altogether.

    Pete

    Comment

    • Stanimir Stoyanov

      #3
      Re: Error in SqlHelper method - vs2005

      Hi Rick,

      It is strange that in the error message the method is ExecuteDataset while
      your second line of code reads ExecuteReader but the method sugnatures are
      the same.

      Can you check which one of the two is true?
      --
      Stanimir Stoyanov
      메이저사이트 순위 먹튀검증이 완료된 토토사이트 커뮤니티 - 토토핫 입니다. 저희 토토핫에서는 베팅할때 필수로 점검해야 되는 안전 가이드를 제공하며 안전한 메이저 놀이터 목록과 메이저사이트 먹튀검증 꽁머니사이트를 추천드립니다.


      "Rick" <Rick@discussio ns.microsoft.co mwrote in message
      news:419F0057-38A5-45B9-B153-70E153ABBD1C@mi crosoft.com...
      Line #2 in the following code generates an error; what am I doing wrong?
      >
      Error 1 The best overloaded method match for
      'Microsoft.Appl icationBlocks.D ata.SqlHelper.E xecuteDataset(s tring,
      System.Data.Com mandType, string)' has some invalid arguments
      >
      Code:
      >
      Line #1 System.Data.Dat aSet dsCust = new System.Data.Dat aSet();
      Line #2 dsCust = SqlHelper.Execu teReader(sqlCon nection,
      CommandType.Tex t, "SELECT * FROM Customer");

      Comment

      • Jeff Johnson

        #4
        Re: Error in SqlHelper method - vs2005

        "Rick" <Rick@discussio ns.microsoft.co mwrote in message
        news:419F0057-38A5-45B9-B153-70E153ABBD1C@mi crosoft.com...
        Line #2 in the following code generates an error; what am I doing wrong?
        >
        Error 1 The best overloaded method match for
        'Microsoft.Appl icationBlocks.D ata.SqlHelper.E xecuteDataset(s tring,
        System.Data.Com mandType, string)' has some invalid arguments
        >
        Code:
        >
        Line #1 System.Data.Dat aSet dsCust = new System.Data.Dat aSet();
        Line #2 dsCust = SqlHelper.Execu teReader(sqlCon nection,
        CommandType.Tex t, "SELECT * FROM Customer");
        I'll mention something unrelated: since you're going to be getting a DataSet
        back from the ExecuteDataset( ) method, there is absolutely no reason to use
        new in the declaration. In fact, you ought to just have one line:

        System.Data.Dat aSet dsCust = SqlHelper.Execu teReader(sqlCon nection,
        CommandType.Tex t, "SELECT * FROM Customer");


        Comment

        Working...