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 8267771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:39:08+00:00 2026-06-08T05:39:08+00:00

am writing code in vb.net .am using select statement in oracle command . when

  • 0

am writing code in vb.net .am using select statement in oracle command . when i pass arguments values through variable am getting error.

my code
------
chk1 = TextBox1.Text
d1 = Date.Parse(chk1)


--------
--------
try
   cn.Open()

        cmd = New OracleCommand("select PHONE from  reports.renewal_contact_t where run_date=to_date('+ d1 +','mm/dd/yyyy') and  EXP_DATE =to_date('07/21/2012','mm/dd/yyyy')", cn)

 ------------
 ada.Fill(ds, "reports.renewal_contact_t ")
end try


eror(in ada.fill statement)
 -----
ORA-01858: a non-numeric character was found where a numeric was expected 
  • 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-06-08T05:39:11+00:00Added an answer on June 8, 2026 at 5:39 am

    You haven’t managed to put your date into your SQL query. You’re getting an error because Oracle cannot convert the string + d1 + into a date of the form mm/dd/yyyy. I get exactly the same error in SQL*Plus:

    SQL> select to_date('+ d1 +', 'mm/dd/yyyy') from dual;
    select to_date('+ d1 +', 'mm/dd/yyyy') from dual
                   *
    ERROR at line 1:
    ORA-01858: a non-numeric character was found where a numeric was expected
    

    There is a way to concatenate the date into the SQL string to get a query that would appear to work, but I’m not going to show you that. I don’t want you to get into the habit of doing this as this puts your code at risk of SQL injection (obligatory XKCD comic link).

    Instead, I recommend that you set the date in your SQL query using a bind parameter. The example code below uses a bind parameter named p_run_date to pass the date d1 into the query, and writes the names of the phones returned by the query to Console.WriteLine.

    I wrote code to do this in C#, tested it to verify that it did what I expected it to, and then attempted to convert it to VB.NET. I haven’t tested this VB.NET code, so there may well be one or two (hopefully minor) errors with the conversion:

        Using OracleCommand cmd As New OracleCommand("select PHONE from reports.renewal_contact_t where run_date=:p_run_date and EXP_DATE =to_date('07/21/2012','mm/dd/yyyy')", cn)
            cmd.Parameters.Add(New OracleParameter() { Direction = ParameterDirection.Input, ParameterName = "p_run_date", OracleDbType = OracleDbType.Date, Value = d1 })
            Using OracleDataReader reader As cmd.ExecuteReader()
                While reader.Read()
                    Console.WriteLine(reader.GetString(0))
                End While
            End Using
        End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was recently writing some code to do WriteLine using a delegate in .NET
I am writing vb.net code to log a user into my application using SQL
I am writing sample code for Date conversion using VB.net. Problem i am facing
I am writing code for a windows application using vb.net. I want to open
I am writing vb.net code to log a user into my application using SQL
I'm using C# .NET 4 and MSSQL. I'm writing a code that downloads the
i am writing some code in vb.net that will be generating a pdf file.
I have been messing around with writing some stored procedures in .NET code with
I am writing an ASP.NET custom control. In my custom control code, I find
I'm writing an application in Visual C++ using the .NET 3.5 Framework, connecting 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.