This is a discussion on Cannot implicitly convert type 'void' to 'System.Data.DataTable' within the C# Programming forums, part of the Software Development category; Cannot implicitly convert type 'void' to 'System.Data.DataTable' private static void FromDictionary(SqlDataReader dr) { string eText = string.Empty; DataTable ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Cannot implicitly convert type 'void' to 'System.Data.DataTable' private static void FromDictionary(SqlDataReader dr) { string eText = string.Empty; DataTable dictionaryWords = new DataTable(); DataTable dt = new DataTable(); dt = dt.Load(dr); if (dr != null) { dictionaryWords = dt; <<<<<<<<<< ERROR: Cannot implicitly convert type 'void' to 'System.Data.DataTable' }
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| Sponsored Links |
| |||
| You probably are returning the datatable. If thats the case, make your function declaration to return a datatable. private static DataTable FromDictionary(SqlDataReader dr) |
| |||
| I would say this line 5 is actually stuff up: dt = dt.Load(dr); // <-- as Load() function is type of void All you need to do is just load with datareader and do no need to assign it back to your dt e.g. dt.load(dr); |
| |||
| I change the code to return DataTable but still same error: private static DataTable FromDictionary(SqlDataReader dr) { DataTable dictionaryWords = new DataTable(); DataTable dt = new DataTable(); if (dr != null) { dictionaryWords = dt.Load(dr); <<<<<<<<<error } Its all about coding!
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
| |||
| First of all, are you even returning a datatable from your method? Also, refer to my previous replies about Load method. |
| |||
| you run into the conversion problem because Load return void. May be this help you. DataTable dictionaryWords = new DataTable();DataTable dt = new DataTable(); dt.Load(dr); if (dr != null) { dictionaryWords = dt; } return dt; |
| |||
| hi..... I got it.... what u said..... thanks.... it works fine..... great ![]()
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Convert Dataview to Datatable | it.wily | C# Programming | 2 | 01-23-2008 02:51 AM |
| What is the difference between "using System.Data;" and directly adding the refer | KiruthikaSambandam | ASP and ASP.NET Programming | 1 | 11-15-2007 01:33 AM |
| Anybody explain about "Common Type System" (CTS)? | H2o | ASP and ASP.NET Programming | 5 | 08-09-2007 08:02 AM |
| void return type | anbuchezhians | Java Programming | 1 | 07-25-2007 05:55 AM |
| Convert integer type variable to char array | oyu2o | C and C++ Programming | 0 | 03-10-2007 09:47 AM |