PC Review


Reply
Thread Tools Rate Thread

best method of querying

 
 
cj2
Guest
Posts: n/a
 
      27th Jun 2008
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;

}
}
}

 
Reply With Quote
 
 
 
 
cfps.Christian
Guest
Posts: n/a
 
      27th Jun 2008
On Jun 27, 10:28*am, cj2 <c...@nospam.nospam> wrote:
> 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()

 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      30th Jun 2008
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 Removed).

==================================================
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 <(E-Mail Removed)>
>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;
>
> }
> }
>}
>
>


 
Reply With Quote
 
cj2
Guest
Posts: n/a
 
      30th Jun 2008
Thank you!

cfps.Christian wrote:
> On Jun 27, 10:28 am, cj2 <c...@nospam.nospam> wrote:
>> 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()
>

 
Reply With Quote
 
cj2
Guest
Posts: n/a
 
      30th Jun 2008
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:
> (E-Mail Removed).
>
> ==================================================
> 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 <(E-Mail Removed)>
>> 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;
>>
>> }
>> }
>> }
>>
>>

>

 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      1st Jul 2008
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 Removed).

==================================================
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 <(E-Mail Removed)>
>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:
>> (E-Mail Removed).
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ObjectDataSource & FormView adding two extra paramaters to Update method giving error non-generic method ... Fred Dag Microsoft ASP .NET 0 18th Sep 2006 11:36 PM
ObjectDataSource & FormView adding two extra paramaters to Update method giving error non-generic method ... Fred Dag Microsoft ADO .NET 0 18th Sep 2006 05:24 AM
Querying a join (Which method is better?) =?Utf-8?B?QnJ1Y2UgT25l?= Microsoft ADO .NET 1 9th Jul 2006 10:09 PM
Consuming webservices from a smart device project ... <Method>Async() web method calls missing in the reference.cs ... Rodrigus Makon Microsoft Dot NET Compact Framework 5 20th May 2006 09:04 AM
querying and re-querying in form? courtney Microsoft Access Form Coding 0 20th Aug 2003 01:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:35 AM.