By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,892 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,892 IT Pros & Developers. It's quick & easy.

RE: best method of querying

P: n/a
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/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 <cj*@nospam.nospam>
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;

}
}
}

Jun 30 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
cj2
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:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.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/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 <cj*@nospam.nospam>
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;

}
}
}

Jun 30 '08 #2

P: n/a
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:
ms****@microsoft.com.

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

--------------------
>Date: Mon, 30 Jun 2008 15:53:01 -0400
From: cj2 <cj*@nospam.nospam>
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:
ms****@microsoft.com.
Jul 1 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.