best method of querying

C

cj2

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.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};" +
"SourceType=DBF;" + "SourceDB=\\\\fileserver\\i\\probill\\;" +
"Exclusive=No;" + "Collate=Machine;" + "NULL=NO;" + "DELETED=NO;" +
"BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.dbf where act = '" + act.Trim
+ "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar();
myOdbcConnection.Close();

return results;

}
}
}
 
C

cfps.Christian

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.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
     /// <summary>
     /// Summary description for Service1
     /// </summary>
     [WebService(Namespace = "http://tempuri.org/")]
     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
     [ToolboxItem(false)]
     // To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
     // [System.Web.Script.Services.ScriptService]
     public class Service1 : System.Web.Services.WebService
     {

         [WebMethod()]
         public string CashOnly(string act)
         {
             DataSet ds = new DataSet();
             OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};" +
"SourceType=DBF;" + "SourceDB=\\\\fileserver\\i\\probill\\;" +
"Exclusive=No;" + "Collate=Machine;" + "NULL=NO;" + "DELETED=NO;"+
"BACKGROUNDFETCH=NO");

             OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.dbf where act = '" + act.Trim
+ "'", myOdbcConnection);
             myOdbcConnection.Open();
             string results = myOdbcCommand.ExecuteScalar();
             myOdbcConnection.Close();

             return results;

         }
     }

}

act.Trim is a method and therefore must have parenthesis

act.Trim should be act.Trim()
 
S

Steven Cheng [MSFT]

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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
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/subscriptions/support/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 <[email protected]>
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.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};" +
"SourceType=DBF;" + "SourceDB=\\\\fileserver\\i\\probill\\;" +
"Exclusive=No;" + "Collate=Machine;" + "NULL=NO;" + "DELETED=NO;" +
"BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.dbf where act = '" + act.Trim
+ "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar();
myOdbcConnection.Close();

return results;

}
}
}
 
C

cj2

Thank you!

cfps.Christian said:
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.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};" +
"SourceType=DBF;" + "SourceDB=\\\\fileserver\\i\\probill\\;" +
"Exclusive=No;" + "Collate=Machine;" + "NULL=NO;" + "DELETED=NO;" +
"BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.dbf where act = '" + act.Trim
+ "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar();
myOdbcConnection.Close();

return results;

}
}

}

act.Trim is a method and therefore must have parenthesis

act.Trim should be act.Trim()
 
C

cj2

Thank you!
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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
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/subscriptions/support/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 <[email protected]>
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.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.Odbc;

namespace CWebService1
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
// To allow this Web Service to be called from script, using
ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{

[WebMethod()]
public string CashOnly(string act)
{
DataSet ds = new DataSet();
OdbcConnection myOdbcConnection = new
OdbcConnection("Driver={Microsoft Visual FoxPro Driver};" +
"SourceType=DBF;" + "SourceDB=\\\\fileserver\\i\\probill\\;" +
"Exclusive=No;" + "Collate=Machine;" + "NULL=NO;" + "DELETED=NO;" +
"BACKGROUNDFETCH=NO");

OdbcCommand myOdbcCommand = new OdbcCommand("select flag
from \\\\fileserver\\i\\probill\\act_frau.dbf where act = '" + act.Trim
+ "'", myOdbcConnection);
myOdbcConnection.Open();
string results = myOdbcCommand.ExecuteScalar();
myOdbcConnection.Close();

return results;

}
}
}
 
S

Steven Cheng [MSFT]

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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

--------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top