Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6896859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:05:48+00:00 2026-05-27T07:05:48+00:00

Basically just pulling a date out in YYYYMMDD and I can do this fine

  • 0

Basically just pulling a date out in YYYYMMDD and I can do this fine in a query analyzer but when I try to run this query in C# I keep getting a column not found error it also seems to have a hard time doing concatenation (but that isn’t so much of a problem) so a little unsure of what is happening here..I really just want my to_char function to work. Ideas? Thanks!

  string oradb = "user id=x;password=x;data source=(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)"
        +"(HOST=x)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=x)));";

    OracleConnection conn = new OracleConnection(oradb);
    conn.Open();

    OracleCommand cmd = new OracleCommand();
    cmd.Connection = conn;
    cmd.CommandType = CommandType.Text; 
    cmd.CommandText =
        "SELECT to_char(ProblemDate, 'yyyymmdd'), data1, data2,"
        +"data4, data5, data6"
        +" WHERE ( ProblemDate >='03-oct-2011' ) "
        +"AND ( ProblemDate <= '08-oct-2011' ) AND " 
        +"( data1 in ( '3','5','6' ) )";
    OracleDataReader dr = cmd.ExecuteReader();

    string fileOut1 = Request.PhysicalApplicationPath;
    string fileOut = fileOut1 + "Text5.txt";
    // Creates the file
    StreamWriter sw = new StreamWriter(fileOut);
    if (dr.HasRows)
    {
        while (dr.Read())
        {
            string data1= (string)dr["data1"].ToString();
            string data2 = (string)dr["data3"].ToString();
            string data3 = (string)dr["data4"];
            string data4 = (string)dr["data5"].ToString();
            string data5 = (string)dr["data6"].ToString();
            string ProblemDate = (string)dr["ProblemDate"].ToString();

            //remove the comma
            char[] MyChar = { ',' };

            sw.WriteLine(data1.PadRight(10) + data2.PadRight(5) + data3.TrimEnd(MyChar) + "000" +
                data4 + "000" + data5+  ProblemDate + "  " + "N" );

            Label1.Text = "File created successfully.<br />";
            Label1.Text += fileOut1;
        }
        // Closes the connenction.
        sw.Close();
        conn.Close();
    }
    else
    {
        Label1.Text = "No data written.";
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:05:49+00:00Added an answer on May 27, 2026 at 7:05 am

    Did you try aliasing the column? eg.

    SELECT to_char(ProblemDate, 'yyyymmdd') as ProblemDate, data1, data2 ...
    

    As a side note, you might run into issues with your date comparisons in your WHERE clause. Granted I don’t know anything about your application, client and/or server regional settings and maybe your example was just for illustration purposes, but I’m thinking it would be safer to use TO_DATE than string comparisons:

    cmd.CommandText =
        "SELECT to_char(ProblemDate, 'yyyymmdd') as ProblemDate, data1, data2,"
        +"data4, data5, data6"
        +" WHERE ( ProblemDate >= TO_DATE('03-oct-2011', 'DD-MON-YYYY') ) "
        +"AND ( ProblemDate <= TO_DATE('08-oct-2011', 'DD-MON-YYYY') ) AND " 
        +"( data1 in ( '3','5','6' ) )";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically just looking to see if you can capture an image from the webcam
Is there an easy (therefore quick) way to accomplish this? Basically just take some
Pardon the simple question, but I am pulling my hair out trying to get
I've been pulling my hair out trying to work with Time in Rails. Basically
I am pulling my hair out with this one. I have a table inside
I have done this before and for some reason I just can't get it
I've searched all over and I can't figure this one out. I am working
I'm writing an application that is basically just a preferences dialog, much like the
One simple method I've used in the past is basically just creating a second
So I have site list on certain pages that basically just have links to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.