Click here to Skip to main content
15,891,828 members
Home / Discussions / C#
   

C#

 
JokeRe: help me in this code Pin
Pete O'Hanlon3-Apr-16 22:57
mvePete O'Hanlon3-Apr-16 22:57 
AnswerRe: help me in this code Pin
Sascha Lefèvre2-Apr-16 5:10
professionalSascha Lefèvre2-Apr-16 5:10 
GeneralRe: help me in this code Pin
OriginalGriff2-Apr-16 6:16
mveOriginalGriff2-Apr-16 6:16 
GeneralRe: help me in this code Pin
Mycroft Holmes2-Apr-16 13:32
professionalMycroft Holmes2-Apr-16 13:32 
GeneralRe: help me in this code Pin
Sascha Lefèvre2-Apr-16 14:15
professionalSascha Lefèvre2-Apr-16 14:15 
GeneralRe: help me in this code Pin
Mycroft Holmes2-Apr-16 16:32
professionalMycroft Holmes2-Apr-16 16:32 
AnswerRe: help me in this code Pin
Suresh73-Apr-16 5:55
Suresh73-Apr-16 5:55 
QuestionInput string was not in a correct format as output in c# console application Pin
KittoKy2-Apr-16 1:48
KittoKy2-Apr-16 1:48 
I haven't used any
Console.WriteLine 
to display "Input string was not in a correct format" Frown | :( . I am trying to get data from database and save it in a double 2D array. One row in each array entry. This is my code :

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;

namespace Outliers2010_Console
{
  class Program
  {
    static void Main(string[] args)
    {            
       try
       {               
          double[][] rawData = new double[20][];           
                
          string con = @"Data Source=Kitty-PC\SQLEXPRESS;Initial Catalog=kitty12;Integrated Security=True";
                
          SqlConnection sql = new SqlConnection(con);
          string cms = "SELECT TOP 20 * FROM churn_or"; 
          SqlCommand cmd = new SqlCommand(cms,sql);         
          sql.Open();
          SqlDataReader dt = cmd.ExecuteReader();          
          int i = 0;
          //populating array
          if (dt.HasRows)
          {
             Console.WriteLine("datareader has rows");
             while (dt.Read())
             { 
                Console.WriteLine("read from dt");
          
                rawData[i] = new double[]    {Convert.ToDouble  (dt[0]), Convert.ToDouble(dt[1]), Convert.ToDouble(dt[2]), Convert.ToDouble(dt[3]), Convert.ToDouble(dt[4]), Convert.ToDouble(dt[5]), Convert.ToDouble(dt[6]), Convert.ToDouble(dt[7]), Convert.ToDouble(dt[8]), Convert.ToDouble(dt[9]), Convert.ToDouble(dt[10]), Convert.ToDouble(dt[11]), Convert.ToDouble(dt[12]), Convert.ToDouble(dt[13]), Convert.ToDouble(dt[14]), Convert.ToDouble(dt[15]), Convert.ToDouble(dt[16]), Convert.ToDouble(dt[17]), Convert.ToDouble(dt[18]), Convert.ToDouble(dt[19]), Convert.ToDouble(dt[20]), Convert.ToDouble(dt[21]), Convert.ToDouble(dt[22]), Convert.ToDouble(dt[23]), Convert.ToDouble(dt[24]), Convert.ToDouble(dt[25]), Convert.ToDouble(dt[26]), Convert.ToDouble(dt[27]), Convert.ToDouble(dt[28]), Convert.ToDouble(dt[29]), Convert.ToDouble(dt[30]), Convert.ToDouble(dt[31]), Convert.ToDouble(dt[32])};

                Console.WriteLine(rawData[i]);
                i++;                           
             }
           }
           sql.Close();
       }
       catch()
       {}
     }
   }
}


I am not getting any error nor exception nor even a message, but in output instead of getting value of rawData which I need to be printed. I am getting "Input string was not in a correct format" Sigh | :sigh: . I have extensively googled and even tried the suggestions Confused | :confused: but all are talking about exceptions and errors which are not solving my issue. haven't found any content like that Cry | :((

modified 2-Apr-16 8:20am.

AnswerRe: Input string was not in a correct format as output in c# console application Pin
OriginalGriff2-Apr-16 2:25
mveOriginalGriff2-Apr-16 2:25 
QuestionWrite/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Mahbubur Rahman Rajib2-Apr-16 0:06
Mahbubur Rahman Rajib2-Apr-16 0:06 
AnswerRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
OriginalGriff2-Apr-16 0:09
mveOriginalGriff2-Apr-16 0:09 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Mahbubur Rahman Rajib2-Apr-16 0:13
Mahbubur Rahman Rajib2-Apr-16 0:13 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
OriginalGriff2-Apr-16 0:19
mveOriginalGriff2-Apr-16 0:19 
AnswerRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Gerry Schmitz2-Apr-16 5:40
mveGerry Schmitz2-Apr-16 5:40 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Mahbubur Rahman Rajib2-Apr-16 5:50
Mahbubur Rahman Rajib2-Apr-16 5:50 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Gerry Schmitz2-Apr-16 6:13
mveGerry Schmitz2-Apr-16 6:13 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Mahbubur Rahman Rajib2-Apr-16 6:17
Mahbubur Rahman Rajib2-Apr-16 6:17 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Gerry Schmitz2-Apr-16 6:25
mveGerry Schmitz2-Apr-16 6:25 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Mahbubur Rahman Rajib4-Apr-16 22:19
Mahbubur Rahman Rajib4-Apr-16 22:19 
GeneralRe: Write/Read ISBN of a book in NXP tag and Turn security ON/OFF Pin
Gerry Schmitz5-Apr-16 5:11
mveGerry Schmitz5-Apr-16 5:11 
QuestionArtificial intelligence Pin
Member 117803991-Apr-16 22:29
Member 117803991-Apr-16 22:29 
AnswerRe: Artificial intelligence Pin
OriginalGriff1-Apr-16 22:44
mveOriginalGriff1-Apr-16 22:44 
AnswerRe: Artificial intelligence Pin
DaveAuld1-Apr-16 23:54
professionalDaveAuld1-Apr-16 23:54 
AnswerRe: Artificial intelligence Pin
Pete O'Hanlon2-Apr-16 1:20
mvePete O'Hanlon2-Apr-16 1:20 
AnswerRe: Artificial intelligence Pin
Gerry Schmitz2-Apr-16 5:32
mveGerry Schmitz2-Apr-16 5:32 

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.