TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
matej kralik
NA
2
0
LINQ stored procedure to select all data from table to datagridview
Oct 6 2008 7:14 AM
Hello people, I need your advice, what to do. I use LINQ stored procedure to select all data from sql table to DataGridView:
EtiketyLINQDataContext EtiketyData = new EtiketyLINQDataContext();
IEnumerable VypisDat = EtiketyData.Vypis("Cislo", "Typ", "Hrubka", "MaterialTyp");
LINQdataGridView.DataSource = VypisDat;
The problem occurs with this line:
IEnumerable VypisDat = EtiketyData.Vypis("Cislo", "Typ", "Hrubka", "MaterialTyp");
...saying 'Cannot implicitly convert type 'int' to 'System.Collections.IEnumerable'.
The stored procedure "Vypis" looks like this:
ALTER PROCEDURE dbo.Vypis
(
@Column1 varchar(50),
@Column2 varchar(50),
@Column3 varchar(50),
@Tablename varchar(50)
)
AS
/*Vypis vsetkych stlpcov tabulky*/
EXEC ('SELECT ' + @Column1 + ', '+@Column2+', '+@Column3+' FROM '+@Tablename)
RETURN
I realize that the problem can be also in bad type in design view of the table, where the code is like this:
[Function(Name = "dbo.Vypis")]
public
int
Vypis([Parameter(Name = "Column1", DbType = "VarChar(50)")] string column1, [Parameter(Name = "Column2", DbType = "VarChar(50)")] string column2, [Parameter(Name = "Column3", DbType = "VarChar(50)")] string column3, [Parameter(Name = "Tablename", DbType = "VarChar(50)")] string tablename)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), column1, column2, column3, tablename);
return ((
int
)(result.ReturnValue));
}
But here, when I change type on
System.Collections.IEnumerable
, I get message:
'System.Collections.IEnumerable' is not a valid return type for a mapped stored procedure method'.
I'm now completely lost, what shall I do... I hope, the explanation is not complicated.
matej
Reply
Answers (
1
)
print - preview Landscape or Portrait
Stop Keystrokes to an active window