RE: best method of querying

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven Cheng [MSFT]

    RE: best method of querying

    Hi Cj,

    I also noticed that the "Act" variable here seems hasn't been declared(or
    declared anywhere else?). I've try building the same code and got the same
    result and the "Operator '+' cannot be applied to operands of type 'string'
    " error does pointing to the "Act.Trim" which should be of method call
    syntax such as Act.Trim()

    After change it, that error is eliminated.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.

    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.


    --------------------
    >Date: Fri, 27 Jun 2008 11:28:28 -0400
    >From: cj2 <cj2@nospam.nos pam>
    >User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
    >MIME-Version: 1.0
    >Subject: best method of querying
    >
    >I just converted this from VB and apparently I need to do something else
    >in C#. What is the problem with my select statement. I'm getting:
    >Operator '+' cannot be applied to operands of type 'string' and 'method
    >group'
    >
    >using System;
    >using System.Collecti ons;
    >using System.Componen tModel;
    >using System.Data;
    >using System.Linq;
    >using System.Web;
    >using System.Web.Serv ices;
    >using System.Web.Serv ices.Protocols;
    >using System.Xml.Linq ;
    >using System.Data.Odb c;
    >
    >namespace CWebService1
    >{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Name space = "http://tempuri.org/")]
    [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
    [ToolboxItem(fal se)]
    // To allow this Web Service to be called from script, using
    >ASP.NET AJAX, uncomment the following line.
    // [System.Web.Scri pt.Services.Scr iptService]
    public class Service1 : System.Web.Serv ices.WebService
    {
    >
    [WebMethod()]
    public string CashOnly(string act)
    {
    DataSet ds = new DataSet();
    OdbcConnection myOdbcConnectio n = new
    >OdbcConnection ("Driver={Micro soft Visual FoxPro Driver};" +
    >"SourceType=DB F;" + "SourceDB=\\\\f ileserver\\i\\p robill\\;" +
    >"Exclusive=No; " + "Collate=Machin e;" + "NULL=NO;" + "DELETED=NO ;" +
    >"BACKGROUNDFET CH=NO");
    >
    OdbcCommand myOdbcCommand = new OdbcCommand("se lect flag
    >from \\\\fileserver\ \i\\probill\\ac t_frau.dbf where act = '" + act.Trim
    >+ "'", myOdbcConnectio n);
    myOdbcConnectio n.Open();
    string results = myOdbcCommand.E xecuteScalar();
    myOdbcConnectio n.Close();
    >
    return results;
    >
    }
    }
    >}
    >
    >
  • cj2

    #2
    Re: best method of querying

    Thank you!

    Steven Cheng [MSFT] wrote:
    Hi Cj,
    >
    I also noticed that the "Act" variable here seems hasn't been declared(or
    declared anywhere else?). I've try building the same code and got the same
    result and the "Operator '+' cannot be applied to operands of type 'string'
    " error does pointing to the "Act.Trim" which should be of method call
    syntax such as Act.Trim()
    >
    After change it, that error is eliminated.
    >
    Sincerely,
    >
    Steven Cheng
    >
    Microsoft MSDN Online Support Lead
    >
    >
    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    msdnmg@microsof t.com.
    >
    =============== =============== =============== =====
    Get notification to my posts through email? Please refer to
    Gain technical skills through documentation and training, earn certifications and connect with the community

    ications.
    >
    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.
    =============== =============== =============== =====
    This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    --------------------
    >Date: Fri, 27 Jun 2008 11:28:28 -0400
    >From: cj2 <cj2@nospam.nos pam>
    >User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
    >MIME-Version: 1.0
    >Subject: best method of querying
    >
    >I just converted this from VB and apparently I need to do something else
    >in C#. What is the problem with my select statement. I'm getting:
    >Operator '+' cannot be applied to operands of type 'string' and 'method
    >group'
    >>
    >using System;
    >using System.Collecti ons;
    >using System.Componen tModel;
    >using System.Data;
    >using System.Linq;
    >using System.Web;
    >using System.Web.Serv ices;
    >using System.Web.Serv ices.Protocols;
    >using System.Xml.Linq ;
    >using System.Data.Odb c;
    >>
    >namespace CWebService1
    >{
    > /// <summary>
    > /// Summary description for Service1
    > /// </summary>
    > [WebService(Name space = "http://tempuri.org/")]
    > [WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
    > [ToolboxItem(fal se)]
    > // To allow this Web Service to be called from script, using
    >ASP.NET AJAX, uncomment the following line.
    > // [System.Web.Scri pt.Services.Scr iptService]
    > public class Service1 : System.Web.Serv ices.WebService
    > {
    >>
    > [WebMethod()]
    > public string CashOnly(string act)
    > {
    > DataSet ds = new DataSet();
    > OdbcConnection myOdbcConnectio n = new
    >OdbcConnection ("Driver={Micro soft Visual FoxPro Driver};" +
    >"SourceType=DB F;" + "SourceDB=\\\\f ileserver\\i\\p robill\\;" +
    >"Exclusive=No; " + "Collate=Machin e;" + "NULL=NO;" + "DELETED=NO ;" +
    >"BACKGROUNDFET CH=NO");
    >>
    > OdbcCommand myOdbcCommand = new OdbcCommand("se lect flag
    >>from \\\\fileserver\ \i\\probill\\ac t_frau.dbf where act = '" + act.Trim
    >+ "'", myOdbcConnectio n);
    > myOdbcConnectio n.Open();
    > string results = myOdbcCommand.E xecuteScalar();
    > myOdbcConnectio n.Close();
    >>
    > return results;
    >>
    > }
    > }
    >}
    >>
    >>
    >

    Comment

    • Steven Cheng [MSFT]

      #3
      Re: best method of querying

      You're welcome Cj,

      If there is anything else we can help, welcome to post in the newsgroup.

      Sincerely,

      Steven Cheng

      Microsoft MSDN Online Support Lead


      Delighting our customers is our #1 priority. We welcome your comments and
      suggestions about how we can improve the support we provide to you. Please
      feel free to let my manager know what you think of the level of service
      provided. You can send feedback directly to my manager at:
      msdnmg@microsof t.com.

      =============== =============== =============== =====
      Get notification to my posts through email? Please refer to
      Gain technical skills through documentation and training, earn certifications and connect with the community

      ications.

      --------------------
      >Date: Mon, 30 Jun 2008 15:53:01 -0400
      >From: cj2 <cj2@nospam.nos pam>
      >User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
      >MIME-Version: 1.0
      >Subject: Re: best method of querying
      >
      >Thank you!
      >
      >Steven Cheng [MSFT] wrote:
      >Hi Cj,
      >>
      >I also noticed that the "Act" variable here seems hasn't been
      declared(or
      >declared anywhere else?). I've try building the same code and got the
      same
      >result and the "Operator '+' cannot be applied to operands of type
      'string'
      >" error does pointing to the "Act.Trim" which should be of method call
      >syntax such as Act.Trim()
      >>
      >After change it, that error is eliminated.
      >>
      >Sincerely,
      >>
      >Steven Cheng
      >>
      >Microsoft MSDN Online Support Lead
      >>
      >>
      >Delighting our customers is our #1 priority. We welcome your comments
      and
      >suggestions about how we can improve the support we provide to you.
      Please
      >feel free to let my manager know what you think of the level of service
      >provided. You can send feedback directly to my manager at:
      >msdnmg@microsof t.com.
      >>

      Comment

      Working...