locked
Implicit conversion from data type datetime to decimal error RRS feed

  • Question

  • I am trying to copy a row from table fprecerttemp to fprecert using the code below but receive the error in the title above.  For reference all the date fields are datetime2(7)

    Any ideas.

          
            Command1.CommandText = "INSERT INTO fprecert " &
                          "SELECT * FROM fprecerttemp " &
                          "WHERE FACCT = " & "'" & FAcct & "'"
    
            Try
                Command1.ExecuteNonQuery()
            Catch SqlExceptionErr As SqlException
                MessageBox.Show(SqlExceptionErr.Message)
                IsError = True
            End Try


    ISV using VB.net and SQL Server

    Friday, September 13, 2019 5:07 PM

Answers

  • The best method is to specify the column names in both parts of the statement.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by Jeff07 Friday, September 13, 2019 6:53 PM
    Friday, September 13, 2019 6:42 PM

All replies

  • The best method is to specify the column names in both parts of the statement.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    • Marked as answer by Jeff07 Friday, September 13, 2019 6:53 PM
    Friday, September 13, 2019 6:42 PM
  • Trying to avoid listing all 321 columns because I am lazy. :)

    It turn out the the two tables were not identical and fixing this eliminated the error message.

    Thanks for you help.


    ISV using VB.net and SQL Server

    Friday, September 13, 2019 6:53 PM