Student Student - 29 days ago 7
C# Question

Why does i cant bind the datasource to my datagridview with result from stored procedure?

My SP :
enter image description here

My C#:
enter image description here

I can't get method

.ToList()
in
eksekusi
for datasource in datagridview, how to solve this?

Answer

The result of the stored procedure is a collection of items (IEnumerable<T>/IQueryable<T>). When you perform FirstOrDefault you retrieve the first item in the collection or default(T) if collection is empty.

The T that you have is not an IEnumerable<T> but an object representing a single record with 3 properties, so you do not have the ToList() extension method.

Please refer to SO Linq FirstOrDefault Documentation to understand more

Comments