PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
VS 2008 [RESOLVED] An overflow occurred while converting to datetime-VBForums
Results 1 to 6 of 6

Thread: [RESOLVED] An overflow occurred while converting to datetime

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Resolved [RESOLVED] An overflow occurred while converting to datetime

    Here is the error that is getting thrown:

    Code:
    System.Data.SqlServerCe.SqlCeException was unhandled
      HResult=-2147467259
      Message="An overflow occurred while converting to datetime."
      NativeError=25933
      Source="SQL Server Compact ADO.NET Data Provider"
      StackTrace:
           at System.Data.SqlServerCe.SqlCeCommand.ProcessResults(Int32 hr)
           at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommandText(IntPtr& pCursor, Boolean& isBaseTableCursor)
           at System.Data.SqlServerCe.SqlCeCommand.ExecuteCommand(CommandBehavior behavior, String method, ResultSetOptions options)
           at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQuery()
           at BloodSugarRecorder2.bloodsugarDataSetTableAdapters.recordTableAdapter.InsertQuery(String name, Nullable`1 adate, Nullable`1 atime, Nullable`1 areading, String anote) in C:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\BloodSugarRecorder2\BloodSugarRecorder2\bloodsugarDataSet.Designer.vb:line 1035
           at BloodSugarRecorder2.Form1.cmdAdd_Click(Object sender, EventArgs e) in C:\Documents and Settings\Owner\My Documents\Visual Studio 2008\Projects\BloodSugarRecorder2\BloodSugarRecorder2\Form1.vb:line 18
           at System.Windows.Forms.Control.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnClick(EventArgs e)
           at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ButtonBase.WndProc(Message& m)
           at System.Windows.Forms.Button.WndProc(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.Run(ApplicationContext context)
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
           at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
           at BloodSugarRecorder2.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException:

  2. #2

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Re: An overflow occurred while converting to datetime

    Here is the code for the button click procedure:

    VB Code:
    1. Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
    2.  
    3.         Dim howell1 As New howell(txtName.Text, CType(txtDate.Text, Date), _
    4.                                   CType(txtTime.Text, Date), _
    5.                                   txtBSReading.Text, txtNotes.Text)
    6.  
    7.         Dim ablooddataset As New bloodsugarDataSet
    8.         Dim aBloodTableAdapter As New bloodsugarDataSetTableAdapters.recordTableAdapter
    9.  
    10.         aBloodTableAdapter.InsertQuery(howell1.GetName, howell1.GetDate, _
    11.                               howell1.GetTime, _
    12.                               howell1.GetBloodSugarReading, _
    13.                               howell1.GetNote)
    14.  
    15.         MsgBox("Blood Sugar has been recorded.")
    16.  
    17.     End Sub

    Here is my form1.designer class

    VB Code:
    1. <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
    2. Partial Class Form1
    3.     Inherits System.Windows.Forms.Form
    4.  
    5.     'Form overrides dispose to clean up the component list.
    6.     <System.Diagnostics.DebuggerNonUserCode()> _
    7.     Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    8.         Try
    9.             If disposing AndAlso components IsNot Nothing Then
    10.                 components.Dispose()
    11.             End If
    12.         Finally
    13.             MyBase.Dispose(disposing)
    14.         End Try
    15.     End Sub
    16.  
    17.     'Required by the Windows Form Designer
    18.     Private components As System.ComponentModel.IContainer
    19.  
    20.     'NOTE: The following procedure is required by the Windows Form Designer
    21.     'It can be modified using the Windows Form Designer.  
    22.     'Do not modify it using the code editor.
    23.     <System.Diagnostics.DebuggerStepThrough()> _
    24.     Private Sub InitializeComponent()
    25.         Me.components = New System.ComponentModel.Container
    26.         Me.Label1 = New System.Windows.Forms.Label
    27.         Me.Label2 = New System.Windows.Forms.Label
    28.         Me.Label3 = New System.Windows.Forms.Label
    29.         Me.Label4 = New System.Windows.Forms.Label
    30.         Me.Label5 = New System.Windows.Forms.Label
    31.         Me.txtDate = New System.Windows.Forms.TextBox
    32.         Me.txtTime = New System.Windows.Forms.TextBox
    33.         Me.txtBSReading = New System.Windows.Forms.TextBox
    34.         Me.txtNotes = New System.Windows.Forms.TextBox
    35.         Me.GroupBox1 = New System.Windows.Forms.GroupBox
    36.         Me.cboboxBSReading = New System.Windows.Forms.ComboBox
    37.         Me.Label6 = New System.Windows.Forms.Label
    38.         Me.txtName = New System.Windows.Forms.TextBox
    39.         Me.DataGridView1 = New System.Windows.Forms.DataGridView
    40.         Me.GroupBox2 = New System.Windows.Forms.GroupBox
    41.         Me.cmdCopyAll = New System.Windows.Forms.Button
    42.         Me.cmdCopy = New System.Windows.Forms.Button
    43.         Me.cmdAdd = New System.Windows.Forms.Button
    44.         Me.cmdSearch = New System.Windows.Forms.Button
    45.         Me.cmdDelete = New System.Windows.Forms.Button
    46.         Me.cmdViewAllRecords = New System.Windows.Forms.Button
    47.         Me.BindingSource1 = New System.Windows.Forms.BindingSource(Me.components)
    48.         Me.BloodsugarDataSet = New BloodSugarRecorder2.bloodsugarDataSet
    49.         Me.GroupBox1.SuspendLayout()
    50.         CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).BeginInit()
    51.         Me.GroupBox2.SuspendLayout()
    52.         CType(Me.BindingSource1, System.ComponentModel.ISupportInitialize).BeginInit()
    53.         CType(Me.BloodsugarDataSet, System.ComponentModel.ISupportInitialize).BeginInit()
    54.         Me.SuspendLayout()
    55.         '
    56.         'Label1
    57.         '
    58.         Me.Label1.AutoSize = True
    59.         Me.Label1.Location = New System.Drawing.Point(21, 26)
    60.         Me.Label1.Name = "Label1"
    61.         Me.Label1.Size = New System.Drawing.Size(44, 13)
    62.         Me.Label1.TabIndex = 0
    63.         Me.Label1.Text = "Name:  "
    64.         '
    65.         'Label2
    66.         '
    67.         Me.Label2.AutoSize = True
    68.         Me.Label2.Location = New System.Drawing.Point(11, 44)
    69.         Me.Label2.Name = "Label2"
    70.         Me.Label2.Size = New System.Drawing.Size(39, 13)
    71.         Me.Label2.TabIndex = 1
    72.         Me.Label2.Text = "Date:  "
    73.         '
    74.         'Label3
    75.         '
    76.         Me.Label3.AutoSize = True
    77.         Me.Label3.Location = New System.Drawing.Point(11, 83)
    78.         Me.Label3.Name = "Label3"
    79.         Me.Label3.Size = New System.Drawing.Size(39, 13)
    80.         Me.Label3.TabIndex = 2
    81.         Me.Label3.Text = "Time:  "
    82.         '
    83.         'Label4
    84.         '
    85.         Me.Label4.AutoSize = True
    86.         Me.Label4.Location = New System.Drawing.Point(153, 44)
    87.         Me.Label4.Name = "Label4"
    88.         Me.Label4.Size = New System.Drawing.Size(117, 13)
    89.         Me.Label4.TabIndex = 3
    90.         Me.Label4.Text = "Blood Sugar Reading:  "
    91.         '
    92.         'Label5
    93.         '
    94.         Me.Label5.AutoSize = True
    95.         Me.Label5.Location = New System.Drawing.Point(153, 90)
    96.         Me.Label5.Name = "Label5"
    97.         Me.Label5.Size = New System.Drawing.Size(44, 13)
    98.         Me.Label5.TabIndex = 4
    99.         Me.Label5.Text = "Notes:  "
    100.         '
    101.         'txtDate
    102.         '
    103.         Me.txtDate.Location = New System.Drawing.Point(56, 41)
    104.         Me.txtDate.Name = "txtDate"
    105.         Me.txtDate.Size = New System.Drawing.Size(61, 20)
    106.         Me.txtDate.TabIndex = 5
    107.         '
    108.         'txtTime
    109.         '
    110.         Me.txtTime.Location = New System.Drawing.Point(56, 83)
    111.         Me.txtTime.Name = "txtTime"
    112.         Me.txtTime.Size = New System.Drawing.Size(61, 20)
    113.         Me.txtTime.TabIndex = 6
    114.         '
    115.         'txtBSReading
    116.         '
    117.         Me.txtBSReading.Location = New System.Drawing.Point(276, 41)
    118.         Me.txtBSReading.Name = "txtBSReading"
    119.         Me.txtBSReading.Size = New System.Drawing.Size(58, 20)
    120.         Me.txtBSReading.TabIndex = 7
    121.         '
    122.         'txtNotes
    123.         '
    124.         Me.txtNotes.Location = New System.Drawing.Point(203, 72)
    125.         Me.txtNotes.Multiline = True
    126.         Me.txtNotes.Name = "txtNotes"
    127.         Me.txtNotes.ScrollBars = System.Windows.Forms.ScrollBars.Vertical
    128.         Me.txtNotes.Size = New System.Drawing.Size(185, 59)
    129.         Me.txtNotes.TabIndex = 8

  3. #3

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Re: An overflow occurred while converting to datetime

    VB Code:
    1. 'GroupBox1
    2.         '
    3.         Me.GroupBox1.Controls.Add(Me.cboboxBSReading)
    4.         Me.GroupBox1.Controls.Add(Me.Label6)
    5.         Me.GroupBox1.Controls.Add(Me.Label2)
    6.         Me.GroupBox1.Controls.Add(Me.Label5)
    7.         Me.GroupBox1.Controls.Add(Me.txtNotes)
    8.         Me.GroupBox1.Controls.Add(Me.txtDate)
    9.         Me.GroupBox1.Controls.Add(Me.txtBSReading)
    10.         Me.GroupBox1.Controls.Add(Me.Label3)
    11.         Me.GroupBox1.Controls.Add(Me.txtTime)
    12.         Me.GroupBox1.Controls.Add(Me.Label4)
    13.         Me.GroupBox1.Location = New System.Drawing.Point(24, 53)
    14.         Me.GroupBox1.Name = "GroupBox1"
    15.         Me.GroupBox1.Size = New System.Drawing.Size(500, 141)
    16.         Me.GroupBox1.TabIndex = 9
    17.         Me.GroupBox1.TabStop = False
    18.         Me.GroupBox1.Text = "Input"
    19.         '
    20.         'cboboxBSReading
    21.         '
    22.         Me.cboboxBSReading.FormattingEnabled = True
    23.         Me.cboboxBSReading.Location = New System.Drawing.Point(380, 41)
    24.         Me.cboboxBSReading.Name = "cboboxBSReading"
    25.         Me.cboboxBSReading.Size = New System.Drawing.Size(106, 21)
    26.         Me.cboboxBSReading.TabIndex = 10
    27.         '
    28.         'Label6
    29.         '
    30.         Me.Label6.AutoSize = True
    31.         Me.Label6.Location = New System.Drawing.Point(351, 44)
    32.         Me.Label6.Name = "Label6"
    33.         Me.Label6.Size = New System.Drawing.Size(23, 13)
    34.         Me.Label6.TabIndex = 10
    35.         Me.Label6.Text = "OR"
    36.         '
    37.         'txtName
    38.         '
    39.         Me.txtName.Location = New System.Drawing.Point(61, 23)
    40.         Me.txtName.Name = "txtName"
    41.         Me.txtName.Size = New System.Drawing.Size(137, 20)
    42.         Me.txtName.TabIndex = 10
    43.         '
    44.         'DataGridView1
    45.         '
    46.         Me.DataGridView1.AutoGenerateColumns = False
    47.         Me.DataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize
    48.         Me.DataGridView1.DataSource = Me.BindingSource1
    49.         Me.DataGridView1.Location = New System.Drawing.Point(12, 270)
    50.         Me.DataGridView1.Name = "DataGridView1"
    51.         Me.DataGridView1.Size = New System.Drawing.Size(512, 112)
    52.         Me.DataGridView1.TabIndex = 11
    53.         '
    54.         'GroupBox2
    55.         '
    56.         Me.GroupBox2.Controls.Add(Me.cmdCopyAll)
    57.         Me.GroupBox2.Controls.Add(Me.cmdCopy)
    58.         Me.GroupBox2.Controls.Add(Me.cmdAdd)
    59.         Me.GroupBox2.Controls.Add(Me.cmdSearch)
    60.         Me.GroupBox2.Controls.Add(Me.cmdDelete)
    61.         Me.GroupBox2.Location = New System.Drawing.Point(24, 200)
    62.         Me.GroupBox2.Name = "GroupBox2"
    63.         Me.GroupBox2.Size = New System.Drawing.Size(500, 64)
    64.         Me.GroupBox2.TabIndex = 12
    65.         Me.GroupBox2.TabStop = False
    66.         Me.GroupBox2.Text = "Actions"
    67.         '
    68.         'cmdCopyAll
    69.         '
    70.         Me.cmdCopyAll.Location = New System.Drawing.Point(390, 19)
    71.         Me.cmdCopyAll.Name = "cmdCopyAll"
    72.         Me.cmdCopyAll.Size = New System.Drawing.Size(75, 39)
    73.         Me.cmdCopyAll.TabIndex = 17
    74.         Me.cmdCopyAll.Text = "Copy All"
    75.         Me.cmdCopyAll.UseVisualStyleBackColor = True
    76.         '
    77.         'cmdCopy
    78.         '
    79.         Me.cmdCopy.Location = New System.Drawing.Point(299, 19)
    80.         Me.cmdCopy.Name = "cmdCopy"
    81.         Me.cmdCopy.Size = New System.Drawing.Size(75, 39)
    82.         Me.cmdCopy.TabIndex = 16
    83.         Me.cmdCopy.Text = "Copy"
    84.         Me.cmdCopy.UseVisualStyleBackColor = True
    85.         '
    86.         'cmdAdd
    87.         '
    88.         Me.cmdAdd.Location = New System.Drawing.Point(208, 19)
    89.         Me.cmdAdd.Name = "cmdAdd"
    90.         Me.cmdAdd.Size = New System.Drawing.Size(75, 39)
    91.         Me.cmdAdd.TabIndex = 15
    92.         Me.cmdAdd.Text = "Add"
    93.         Me.cmdAdd.UseVisualStyleBackColor = True
    94.         '
    95.         'cmdSearch
    96.         '
    97.         Me.cmdSearch.Location = New System.Drawing.Point(117, 19)
    98.         Me.cmdSearch.Name = "cmdSearch"
    99.         Me.cmdSearch.Size = New System.Drawing.Size(75, 39)
    100.         Me.cmdSearch.TabIndex = 14
    101.         Me.cmdSearch.Text = "Search"
    102.         Me.cmdSearch.UseVisualStyleBackColor = True
    103.         '
    104.         'cmdDelete
    105.         '
    106.         Me.cmdDelete.Location = New System.Drawing.Point(26, 19)
    107.         Me.cmdDelete.Name = "cmdDelete"
    108.         Me.cmdDelete.Size = New System.Drawing.Size(75, 39)
    109.         Me.cmdDelete.TabIndex = 13
    110.         Me.cmdDelete.Text = "Delete"
    111.         Me.cmdDelete.UseVisualStyleBackColor = True
    112.         '
    113.         'cmdViewAllRecords
    114.         '
    115.         Me.cmdViewAllRecords.Location = New System.Drawing.Point(414, 8)
    116.         Me.cmdViewAllRecords.Name = "cmdViewAllRecords"
    117.         Me.cmdViewAllRecords.Size = New System.Drawing.Size(110, 39)
    118.         Me.cmdViewAllRecords.TabIndex = 13
    119.         Me.cmdViewAllRecords.Text = "View All Records"
    120.         Me.cmdViewAllRecords.UseVisualStyleBackColor = True
    121.         '
    122.         'BindingSource1
    123.         '
    124.         Me.BindingSource1.DataSource = Me.BloodsugarDataSet
    125.         Me.BindingSource1.Position = 0
    126.         '
    127.         'BloodsugarDataSet
    128.         '
    129.         Me.BloodsugarDataSet.DataSetName = "bloodsugarDataSet"
    130.         Me.BloodsugarDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema
    131.         '
    132.         'Form1
    133.         '
    134.         Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    135.         Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    136.         Me.ClientSize = New System.Drawing.Size(547, 394)
    137.         Me.Controls.Add(Me.cmdViewAllRecords)
    138.         Me.Controls.Add(Me.GroupBox2)
    139.         Me.Controls.Add(Me.DataGridView1)
    140.         Me.Controls.Add(Me.txtName)
    141.         Me.Controls.Add(Me.GroupBox1)
    142.         Me.Controls.Add(Me.Label1)
    143.         Me.Name = "Form1"
    144.         Me.Text = "Blood Sugar Recorder"
    145.         Me.GroupBox1.ResumeLayout(False)
    146.         Me.GroupBox1.PerformLayout()
    147.         CType(Me.DataGridView1, System.ComponentModel.ISupportInitialize).EndInit()
    148.         Me.GroupBox2.ResumeLayout(False)
    149.         CType(Me.BindingSource1, System.ComponentModel.ISupportInitialize).EndInit()
    150.         CType(Me.BloodsugarDataSet, System.ComponentModel.ISupportInitialize).EndInit()
    151.         Me.ResumeLayout(False)
    152.         Me.PerformLayout()
    153.  
    154.     End Sub
    155.     Friend WithEvents Label1 As System.Windows.Forms.Label
    156.     Friend WithEvents Label2 As System.Windows.Forms.Label
    157.     Friend WithEvents Label3 As System.Windows.Forms.Label
    158.     Friend WithEvents Label4 As System.Windows.Forms.Label
    159.     Friend WithEvents Label5 As System.Windows.Forms.Label
    160.     Friend WithEvents txtDate As System.Windows.Forms.TextBox
    161.     Friend WithEvents txtTime As System.Windows.Forms.TextBox
    162.     Friend WithEvents txtBSReading As System.Windows.Forms.TextBox
    163.     Friend WithEvents txtNotes As System.Windows.Forms.TextBox
    164.     Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    165.     Friend WithEvents Label6 As System.Windows.Forms.Label
    166.     Friend WithEvents cboboxBSReading As System.Windows.Forms.ComboBox
    167.     Friend WithEvents txtName As System.Windows.Forms.TextBox
    168.     Friend WithEvents DataGridView1 As System.Windows.Forms.DataGridView
    169.     Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    170.     Friend WithEvents cmdCopyAll As System.Windows.Forms.Button
    171.     Friend WithEvents cmdCopy As System.Windows.Forms.Button
    172.     Friend WithEvents cmdAdd As System.Windows.Forms.Button
    173.     Friend WithEvents cmdSearch As System.Windows.Forms.Button
    174.     Friend WithEvents cmdDelete As System.Windows.Forms.Button
    175.     Friend WithEvents BloodsugarDataSetBindingSource As System.Windows.Forms.BindingSource
    176.     Friend WithEvents cmdViewAllRecords As System.Windows.Forms.Button
    177.     Friend WithEvents BindingSource1 As System.Windows.Forms.BindingSource
    178.     Friend WithEvents BloodsugarDataSet As BloodSugarRecorder2.bloodsugarDataSet
    179.  
    180. End Class

    The error is being thrown at the add button click procedure. I am creating queries through a TableAdapter because I don't know much about database programming.

    The two date variables that are stored in the database, the parameter's index for both date variables, and the variables in my business class are all using either date or datetime variable type.

    When I create the class that creates all the information to be added to the database; I have to perform a conversion from string to date by using the CType function. But it seems like the ms sql database programming library is causing the error.

    Hopefully, somebody can help me figure out why I'm getting an overflow error while converting to datetime.

    Thanks!

  4. #4
    Fanatic Member
    Join Date
    Mar 2008
    Posts
    519

    Re: An overflow occurred while converting to datetime

    Hi!

    Just want to say this quickly; when asking for help, you should only include code relevant to the problem. As for now, I didn't read the whole code cause of the irrelevance.

    However, tiny questions which might point you to the right direction:
    1. Is your database using the same datetime format as your application?
    Remember that different countries use different formats.
    2. Did you use the CType like this?
    vb.net Code:
    1. CType([Enum].Parse(GetType(DayOfWeek), 1), String) 'Monday
    (Just an example with DayOfWeek)

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Re: An overflow occurred while converting to datetime

    I just thought there was more of an issue than where the line of code was getting caught at.

    No, I didn't use the CType like that. I wrote it like CType(txtDate.text, Date) and CType(txtTime.text, Date), where the date was equal to 11/20/2010 and the time was equal to "3:30 PM". The date and time get set into the text box by using a statement like that, Date.now.toString("MM/dd/yyyy") and the time get formatted as such, Date.now.toString("hh:mm tt")

    As far as I can see the database data type is set to datetime, the parameters for the queries are set to datetime, and in my code I'm using date.

    Sorry about including too much code. I just thought the issue was somewhere else and didn't know where the problem was lying.

  6. #6

    Thread Starter
    Member
    Join Date
    Jun 2007
    Posts
    35

    Re: An overflow occurred while converting to datetime

    I figured out the problem. The number of characters for the date/time in a MS SQL is 8 characters. "11/26/2010" is more than 8 characters so that was causing an error.

    Well, I guess I know of one additional thing to add to the things that I look for to avoid errors in the future. Make sure that I am not trying to save more character data in a column than has been allowed by the DBMS.

    Thanks for replying Zeelia. You solved my problem with "1. Is your database using the same datetime format as your application?" because that was indeed the problem (Too many characters!).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width