No overload for method 'GetDataByClassType'takes '1' arguments

M

Mucahit ikiz

Can you help me please,
I have this error message

"No overload for method 'GetDataByClassType'takes '1' arguments"



private void button7_Click(object sender, EventArgs e)
{
string connString = @"Data Source=.;Initial
Catalog=Northwind;Integrated Security=True";
DataClasses1DataContext dc = new
DataClasses1DataContext(connString);
Table<Customer> custom = dc.Customers;

// *****This row is wrong,
dataGridView1.DataSource =
GetDataByClassType<Customer>(custom)();
//No overload for method 'GetDataByClassType'takes
'1' arguments
}

public List<T> GetDataByClassType<T>() where T : class
{
string connString = @"Data Source=MUSTAFAC;Initial
Catalog=Northwind;Integrated Security=True";
DataClasses1DataContext dc = new
DataClasses1DataContext(connString);
return Enumerable.ToList<T>(dc.GetTable<T>());
}
 
A

Alex Meleta

Hi Mucahit,

You have no arguments for the method GetDataByClassType<T>() but provide
the value 'custom' instead. Either add the argument to the arguments list
'public List<T> GetDataByClassType<T>(T t) where T : class' or remove 'custom'
from calling
'GetDataByClassType<Customer>()()'. Depends

Regards, Alex Meleta
mailto:[email protected]; blog:devkids.blogspot.co
 
M

Mucahit ikiz

Thanks for answer Alex,
But how can i this method ,

your script block give me error,

plaese , send me code block for this method,
 
A

Alex Meleta

Hi Mucahit,

Which one? I gave you both. Actually your method GetDataByClassType<T>()
doesn't have an arguments but you try to provide custom. As example solution:

dataGridView1.DataSource = GetDataByClassType<Customer>();

Regards, Alex Meleta
mailto:[email protected]; blog:devkids.blogspot.com
 

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