Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: string Pin
OriginalGriff11-Apr-18 0:26
mveOriginalGriff11-Apr-18 0:26 
GeneralRe: string Pin
Richard MacCutchan11-Apr-18 1:44
mveRichard MacCutchan11-Apr-18 1:44 
GeneralRe: string Pin
OriginalGriff11-Apr-18 1:51
mveOriginalGriff11-Apr-18 1:51 
QuestionC# Integrating With Skype Pin
Gavin Coates10-Apr-18 9:45
Gavin Coates10-Apr-18 9:45 
AnswerRe: C# Integrating With Skype Pin
Richard MacCutchan10-Apr-18 11:08
mveRichard MacCutchan10-Apr-18 11:08 
GeneralRe: C# Integrating With Skype Pin
Gavin Coates11-Apr-18 3:13
Gavin Coates11-Apr-18 3:13 
AnswerRe: C# Integrating With Skype Pin
Gerry Schmitz10-Apr-18 11:21
mveGerry Schmitz10-Apr-18 11:21 
Questionexcel udf returns only the first column name in order to display a two dimentional array Pin
Gtari Abir10-Apr-18 6:16
Gtari Abir10-Apr-18 6:16 
I created an excel user defined function using excel dna Add-In, My function should return a two dimentional array but when i call it from a cell (=mainView(2018-04-10) ) it displays only the first column name (FundName), below is my code:

<pre> public static object[,] mainView(DateTime dt)
    {
        int rows = 0;
        int columns = 0;
        const int columnsArrayIndex = 0;
        DataTable dt = new DataTable();
        object[,] allRecords = new object[0,0];           
        try
        {
            SqlConnection cnx = new SqlConnection("data source=...;initial catalog=...;integrated security=True");
            cnx.Open();
            string query = @"select FundName,...";
            SqlCommand cmd = new SqlCommand(query, cnx);
            using (SqlDataAdapter a = new SqlDataAdapter(cmd))
            {
                a.Fill(dt);
                rows = dt.Rows.Count;
                columns = dt.Columns.Count;
                if (columns > 0 && rows > 0)
                {
                    allRecords = new object[rows + 1, columns];
                    for (int i = 0; i <= columns - 1; i++)
                    {
                        allRecords[columnsArrayIndex, i] = dt.Columns[i].ColumnName;
                    }
                    for (int j = 0; j <= rows - 1; j++)
                    {
                        var rowItem = dt.Rows[j].ItemArray;
                        for (int k = 0; k <= rowItem.Length - 1; k++)
                        {
                            allRecords[j + 1, k] = rowItem[k];
                        }
                    }
                }
            }
        }
        catch
        {

        }

        return allRecords; 
    }
I would like to get all the rows of the select query result displayed in the excel, the result of the select query is dynamic, it changes when the date changes. What is missing in my code please so that i can get the result i want ? how can i display all the rows and columns of my query in the excel ?
AnswerRe: excel udf returns only the first column name in order to display a two dimentional array Pin
Richard Andrew x6410-Apr-18 6:57
professionalRichard Andrew x6410-Apr-18 6:57 
AnswerRe: excel udf returns only the first column name in order to display a two dimentional array Pin
Luc Pattyn10-Apr-18 13:03
sitebuilderLuc Pattyn10-Apr-18 13:03 
GeneralRe: excel udf returns only the first column name in order to display a two dimentional array Pin
Gtari Abir12-Apr-18 0:13
Gtari Abir12-Apr-18 0:13 
GeneralRe: excel udf returns only the first column name in order to display a two dimentional array Pin
Luc Pattyn12-Apr-18 3:09
sitebuilderLuc Pattyn12-Apr-18 3:09 
QuestionIssues in ajax call in MVC Pin
Dhyanga9-Apr-18 5:41
Dhyanga9-Apr-18 5:41 
AnswerRe: Issues in ajax call in MVC Pin
Dhyanga9-Apr-18 6:50
Dhyanga9-Apr-18 6:50 
QuestionSyntax of creating the following matrix in C# Pin
Shibe19959-Apr-18 1:00
Shibe19959-Apr-18 1:00 
AnswerRe: Syntax of creating the following matrix in C# Pin
Gerry Schmitz9-Apr-18 2:27
mveGerry Schmitz9-Apr-18 2:27 
AnswerRe: Syntax of creating the following matrix in C# Pin
Dave Kreskowiak9-Apr-18 4:28
mveDave Kreskowiak9-Apr-18 4:28 
AnswerRe: Syntax of creating the following matrix in C# Pin
BillWoodruff11-Apr-18 8:26
professionalBillWoodruff11-Apr-18 8:26 
Questiongeneric type with value parameter rather than type parameter Pin
Alexander Kindel7-Apr-18 11:19
Alexander Kindel7-Apr-18 11:19 
AnswerRe: generic type with value parameter rather than type parameter Pin
OriginalGriff7-Apr-18 23:27
mveOriginalGriff7-Apr-18 23:27 
GeneralRe: generic type with value parameter rather than type parameter Pin
Alexander Kindel8-Apr-18 0:46
Alexander Kindel8-Apr-18 0:46 
GeneralRe: generic type with value parameter rather than type parameter Pin
OriginalGriff8-Apr-18 1:15
mveOriginalGriff8-Apr-18 1:15 
AnswerRe: generic type with value parameter rather than type parameter Pin
BillWoodruff8-Apr-18 3:39
professionalBillWoodruff8-Apr-18 3:39 
AnswerRe: generic type with value parameter rather than type parameter Pin
#realJSOP8-Apr-18 5:36
mve#realJSOP8-Apr-18 5:36 
GeneralRe: generic type with value parameter rather than type parameter Pin
Alexander Kindel8-Apr-18 11:30
Alexander Kindel8-Apr-18 11:30 

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.