Click here to Skip to main content
15,879,474 members
Home / Discussions / C#
   

C#

 
GeneralRe: Removing a field from jSon String Pin
simpledeveloper12-Jun-20 9:05
simpledeveloper12-Jun-20 9:05 
GeneralRe: Removing a field from jSon String Pin
OriginalGriff12-Jun-20 9:06
mveOriginalGriff12-Jun-20 9:06 
AnswerRe: Removing a field from jSon String Pin
James Curran17-Jun-20 20:23
James Curran17-Jun-20 20:23 
QuestionIs there any good C# desktop library to implement Card liked UI dashboard? Pin
yccheok11-Jun-20 6:31
yccheok11-Jun-20 6:31 
AnswerRe: Is there any good C# desktop library to implement Card liked UI dashboard? Pin
Richard MacCutchan11-Jun-20 21:36
mveRichard MacCutchan11-Jun-20 21:36 
GeneralRe: Is there any good C# desktop library to implement Card liked UI dashboard? Pin
yccheok12-Jun-20 6:13
yccheok12-Jun-20 6:13 
GeneralRe: Is there any good C# desktop library to implement Card liked UI dashboard? Pin
Richard MacCutchan12-Jun-20 6:43
mveRichard MacCutchan12-Jun-20 6:43 
QuestionHow to handle excel - multiple sheets integration with ODBC Driver connection in C# Pin
Member 1485915110-Jun-20 3:10
Member 1485915110-Jun-20 3:10 
Hello Everyone,

I'm currently trying to fetch data from 1 excel workbook, which is having multiple sheets

Please find my excel sheet: here

Please find my code to get the excel data

C#
<pre>public static T GetAllTestData<T>(string keyName)
        {
            using (var connection = new
                          OdbcConnection(TestDataFileConnection()))
            {
                connection.Open();
                System.Data.DataTable dt = null;
                dt = connection.GetSchema(OdbcMetaDataCollectionNames.Tables, null);
                String[] excelSheets = new String[dt.Rows.Count];
                var i = 0;
                // Add the sheet name to the string array.
                foreach (DataRow row in dt.Rows)
                {
                    excelSheets[i] = row["TABLE_NAME"].ToString();
                    i++;
                }
                T value = default(T);
                // Loop through all of the sheets if you want to...
                for (int j = 0; j < excelSheets.Length; j++)
                {
                    // Query each excel sheet.
                    var query = string.Format("select * from [{0}] where TestName = '{1}'", excelSheets[j], keyName);
                    value = connection.Query<T>(query).FirstOrDefault();
                }
                //Console.Write(list1);
                connection.Close();
                return value;
            }
        }



Call to the function:

var param1 = AccessExcelData.GetAllTestData<TestDataModel>("Test1");


Issue:

I want to get all the values from all the sheets in excel which has TestName as "Test1" but in my method, variable value keep getting override which makes it tough for me to get all the values

Can someone look into this, or If I can have another approach for handling excel data test in c#
AnswerRe: How to handle excel - multiple sheets integration with ODBC Driver connection in C# Pin
jsc423-Jul-20 6:43
professionaljsc423-Jul-20 6:43 
QuestionSystem.Timers.Timer() called method doesn't run all code Pin
jsmjsm10-Jun-20 1:09
jsmjsm10-Jun-20 1:09 
AnswerRe: System.Timers.Timer() called method doesn't run all code Pin
Richard Deeming10-Jun-20 1:30
mveRichard Deeming10-Jun-20 1:30 
AnswerRe: System.Timers.Timer() called method doesn't run all code Pin
Luc Pattyn10-Jun-20 1:31
sitebuilderLuc Pattyn10-Jun-20 1:31 
QuestionUnable to load file or assembly 'Oracle.DataAccess' Pin
Member 1483395810-Jun-20 0:30
Member 1483395810-Jun-20 0:30 
AnswerRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
OriginalGriff10-Jun-20 0:40
mveOriginalGriff10-Jun-20 0:40 
AnswerRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Dave Kreskowiak10-Jun-20 2:14
mveDave Kreskowiak10-Jun-20 2:14 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Member 1483395810-Jun-20 5:33
Member 1483395810-Jun-20 5:33 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Dave Kreskowiak10-Jun-20 19:17
mveDave Kreskowiak10-Jun-20 19:17 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Member 1483395811-Jun-20 3:00
Member 1483395811-Jun-20 3:00 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Dave Kreskowiak11-Jun-20 3:21
mveDave Kreskowiak11-Jun-20 3:21 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Member 1483395811-Jun-20 3:47
Member 1483395811-Jun-20 3:47 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Dave Kreskowiak11-Jun-20 3:50
mveDave Kreskowiak11-Jun-20 3:50 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Member 1483395811-Jun-20 6:31
Member 1483395811-Jun-20 6:31 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Dave Kreskowiak11-Jun-20 7:55
mveDave Kreskowiak11-Jun-20 7:55 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Jörgen Andersson11-Jun-20 8:34
professionalJörgen Andersson11-Jun-20 8:34 
GeneralRe: Unable to load file or assembly 'Oracle.DataAccess' Pin
Member 1483395811-Jun-20 21:24
Member 1483395811-Jun-20 21:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.