Click here to Skip to main content
15,887,812 members
Home / Discussions / Database
   

Database

 
Generalquestion about connections to a sql server Pin
metalsandman28-Jun-05 3:51
metalsandman28-Jun-05 3:51 
GeneralRe: question about connections to a sql server Pin
Colin Angus Mackay28-Jun-05 4:41
Colin Angus Mackay28-Jun-05 4:41 
GeneralCrystal Report Threw internal Exception Pin
agmb28-Jun-05 3:37
agmb28-Jun-05 3:37 
GeneralForce SELECT to return a single row Pin
BinaryHead28-Jun-05 0:59
BinaryHead28-Jun-05 0:59 
GeneralRe: Force SELECT to return a single row Pin
Colin Angus Mackay28-Jun-05 1:17
Colin Angus Mackay28-Jun-05 1:17 
GeneralRe: Force SELECT to return a single row Pin
P A N K A J28-Jun-05 17:48
P A N K A J28-Jun-05 17:48 
GeneralGet file name using SQL Pin
Wilbur J. Pereira28-Jun-05 0:16
Wilbur J. Pereira28-Jun-05 0:16 
QuestionSpecified cast is not valid? Pin
WetRivrRat27-Jun-05 13:36
WetRivrRat27-Jun-05 13:36 
Hello all,
I"m trying to write the core portion of a app that will sum the total amount (Amount)of money collected from start to end of a shift(Shift_Number), then return that value to (-currently-) the Console. I can get the the app to run, take the inputs of the machine name (Location_ID) and the last shift (Shift_Number), but it failes after it takes the last input,I get "Specified cast is not valid". I've enclosed the code, the database is sql, i'm sure you could change it to northwind and find a table with some numbers to sum and check against. written in C#, and using the console app template...
any help will be most apreciated!

<code>static void Main(string[] args)
{
    try
    {
        SqlConnection LoadLastConnection = new SqlConnection();
        LoadLastConnection.ConnectionString = "User ID=blah;Password=Blah;Initial Catalog=sellmdat2kSQL;Data Source=jpltpharos";
        LoadLastConnection.Open();
        Console.Write("Please enter a Machine_Number(4 characters): ");
        string Machine_Number = Console.ReadLine();
        Console.Write("Please enter the Last_Shift_Number(4 characters): ");
        string Last_Shift_Number = Console.ReadLine();
        SqlCommand LoadLastInvoiceCmd = new SqlCommand();
        LoadLastInvoiceCmd.Connection = LoadLastConnection;
        //LoadLastInvoiceCmd.CommandText = "SELECT sum (Amount) From Transaction_table WHERE Location_ID = 'va60' and Shift_Number = 1" ;

        LoadLastInvoiceCmd.CommandText = "SELECT sum (Amount) From Transaction_table WHERE Location_ID = @machineName and Shift_Number = @ShiftNumber" ;
        LoadLastInvoiceCmd.Parameters.Add("@machineName", Machine_Number);
        LoadLastInvoiceCmd.Parameters.Add("@ShiftNumber", Last_Shift_Number);
        SqlDataReader dataReader = LoadLastInvoiceCmd.ExecuteReader();
        while (dataReader.Read())
        {
            int last_invoice = dataReader.GetInt32(0);
            string Amount = dataReader.GetString(1);
            Console.WriteLine("Current Invoice Period is {0}\nAnd the Cash Value is {1}\nTotal Dollars", last_invoice, Amount);

        }
        dataReader.Close();
        LoadLastConnection.Close();
    }
    catch(Exception e)
    {
        Console.WriteLine("An error occurred accessing the database:" + e.Message);
    }
}</code>


Dim Beautiful As String
Beautiful = "ignorant"
Label1.Text = "The world is full of " & Beautiful & " people."


Why is common sense such an un-common comodity?
AnswerRe: Specified cast is not valid? Pin
Christian Graus27-Jun-05 19:58
protectorChristian Graus27-Jun-05 19:58 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 13:04
WetRivrRat28-Jun-05 13:04 
GeneralRe: Specified cast is not valid? Pin
Christian Graus28-Jun-05 13:18
protectorChristian Graus28-Jun-05 13:18 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 13:33
WetRivrRat28-Jun-05 13:33 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 14:32
WetRivrRat28-Jun-05 14:32 
GeneralRe: Specified cast is not valid? Pin
Christian Graus28-Jun-05 14:55
protectorChristian Graus28-Jun-05 14:55 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 15:52
WetRivrRat28-Jun-05 15:52 
GeneralRe: Specified cast is not valid? Pin
Christian Graus28-Jun-05 17:07
protectorChristian Graus28-Jun-05 17:07 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 17:13
WetRivrRat28-Jun-05 17:13 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 17:14
WetRivrRat28-Jun-05 17:14 
GeneralRe: Specified cast is not valid? Pin
Christian Graus28-Jun-05 17:47
protectorChristian Graus28-Jun-05 17:47 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 18:11
WetRivrRat28-Jun-05 18:11 
GeneralRe: Specified cast is not valid? Pin
Christian Graus28-Jun-05 18:27
protectorChristian Graus28-Jun-05 18:27 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat28-Jun-05 18:51
WetRivrRat28-Jun-05 18:51 
GeneralRe: Specified cast is not valid? Pin
Christian Graus28-Jun-05 18:59
protectorChristian Graus28-Jun-05 18:59 
GeneralRe: Specified cast is not valid? Pin
WetRivrRat29-Jun-05 13:45
WetRivrRat29-Jun-05 13:45 
GeneralImporting a CSV File Into Oracle Pin
wayevans27-Jun-05 10:38
wayevans27-Jun-05 10:38 

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.