?
Solved

c# error

Posted on 2008-11-05
4
Medium Priority
?
228 Views
Last Modified: 2012-05-05
The error reads: "Method must have a return type"

Here is the method:  I am new to c#.  What is wrong with this?

 private getDataSet(DataSet strqry)
        {
           DataSet dsData = new DataSet();
           string ConnectionString = "";
           ConnectionString = " Initial Catalog=CompassCustomer; Data Source=sqlserver5; " +
           "uid=asocefp; password=asocefp";
           
           SqlDataAdapter adapter = new SqlDataAdapter(strqry, ConnectionString);
           
            adapter.Fill(dsData);
            Return (dsData);
        }
0
Comment
Question by:dchau12
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
vbsquickresponse earned 2000 total points
ID: 22886034
you must provide the return type...

private DataSet getDataSet(DataSet strqry)
{
           DataSet dsData = new DataSet();
           string ConnectionString = "";
           ConnectionString = " Initial Catalog=CompassCustomer; Data Source=sqlserver5; " +
           "uid=asocefp; password=asocefp";
           
           SqlDataAdapter adapter = new SqlDataAdapter(strqry, ConnectionString);
           
            adapter.Fill(dsData);
            Return (dsData);
}
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 22886063
Hello dchau12,

vbsquickresponse is correct, though you also need to correctly type the input parameter as you are not passing in a DataSet:

private DataSet getDataSet(String strqry) {
 .....

Regards,

TimCottee
0
 

Author Closing Comment

by:dchau12
ID: 31513516
thanks
0
 
LVL 2

Expert Comment

by:vbsquickresponse
ID: 22886102
Few thinks need to be change in above code...

1. Add return data type, incase this case DataSet type.
2. stryqry should be String - prividing SQL Query
3. adapter.Fill(dsData ,"TableName");
4. retrun dsData
private DataSet getDataSet(DataSet strqry)
{
    DataSet dsData = new DataSet();
    string ConnectionString = "";
    
    ConnectionString = " Initial Catalog=CompassCustomer; Data Source=sqlserver5; " + "uid=asocefp; password=asocefp";
           
    SqlDataAdapter adapter = new SqlDataAdapter(strqry, ConnectionString);
            
    adapter.Fill(dsData ,"TableName");
    retun dsData;
}

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month14 days, 17 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question