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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:51:25+00:00 2026-06-12T06:51:25+00:00

In a windows application I have a query that im trying to insert the

  • 0

In a windows application I have a query that im trying to insert the current date on my mysql database

query below:

SqlVentaCasas1 = "INSERT INTO VentaCasasHistory (ID, Direccion, Estatus, Precio, " & _
                                "NumeroDias, FechaHoy, Agente, Compania, Unidad, Ciudad ) VALUES ('" & _
                                AddIDCasas2 & "','" & AddDireccionCasas2 & "','" & AddEstatusCasas2 & "'," & AddPrecioCasas2 & ", 0, CURDATE(), '" & AgenteNameCasas2 & "','" & AgenteCompaniaCasas2 & "', '" & AddUnidadCasas2 & "', '" & AddCiudadCasas2 & "' );"


                        CommandVentaCasas1 = New MySqlCommand(SqlVentaCasas1, con)
                        CommandVentaCasas1.CommandType = CommandType.Text
                        CommandVentaCasas1.ExecuteNonQuery()

when i input the values that i want to insert into mysql everything runs smoothly except that when i check the database for the date entered i find myself with the 0000-00-00

on the other hand, when i run the same query from PHPmyAdmin

INSERT INTO `VentaCasasHistory`(`ID`, `Direccion`, `Estatus`, `Precio`, `NumeroDias`, `FechaHoy`, `Agente`, `Compania`, `Unidad`, `Ciudad`) VALUES ([String1],[String2],[String3],[Integer1],[Integer2],CURDATE(),[String4],[String5],[String6],[String7])

where FechaHoy is CURDATE() is does insert correctly the date that should be.

I cant seem to find what is the problem, As i understand it will only insert 0000-00-00 if there is something wrong with the date when been entered.

the reason i kept both queries “identical” was to understand what im doing wrong and I know that they can be subject to SQL injection.

your help would be very appreciated.

Leo P.

this is the code i have for the last piece that you told me.

Dim StringDate As String

    StringDate = Date.Today.ToString("yyyy-MM-dd")

SqlVentaCasas1 = "INSERT INTO VentaCasasHistory (ID, Direccion, Estatus, Precio, " & _
                                "NumeroDias, FechaHoy, Agente, Compania, Unidad, Ciudad ) VALUES ('" & _
                                AddIDCasas2 & "','" & AddDireccionCasas2 & "','" & AddEstatusCasas2 & "'," & AddPrecioCasas2 & ", 0, STR_TO_DATE('" & StringDate & "', GET_FORMAT(DATE,'ISO')), '" & AgenteNameCasas2 & "','" & AgenteCompaniaCasas2 & "', '" & AddUnidadCasas2 & "', '" & AddCiudadCasas2 & "' );"

unfortunately it does not work and i still get the 0000-00-00.

  • 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-12T06:51:26+00:00Added an answer on June 12, 2026 at 6:51 am

    CURDATE() should really be specified as default value used in CREATE TABLE. In other words, you don’t need to put it in as part of a query as when you insert a new record the field with default value set to CURDATE() will have the date automatically inserted.

    F.ex:

    CREATE TABLE MyTable
    (
        ID int NOT NULL,
        MyName varchar(30) NOT NULL,
        MyDate datetime NOT NULL DEFAULT CURDATE(),
        PRIMARY KEY (ID)
    )
    
    INSERT INTO MyTable (MyName) VALUES ('Epistemex')
    

    Will set the MyDate field to CURDATE().

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a simple Windows Forms application that can query the capabilities
I am using windows application and I have four combo boxes(comboeventname,combosendtype,comboType,comboschedule) in that form....
Today we have a windows application that, using an OCX, creates a web page
I have one .net windows application I'm trying to read .xml file from c#
I have installed my windows application that uses TeeChart ActiveX (a COM Component for
I have a C# Windows application that I want to ensure will show up
Im using c# .net windows form application. I have created a database which has
I have a VB.NET windows application that when I debug it, it opens the
I have windows mobile application that display information from an sql server ce. Normally
i have a client that runs a windows application on a sql server 2000

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.