Error - SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
แก้ยังไงครับ ช่วยผมหน่อยครับ
Code (VB.NET)
Imports System.Data.SqlClient
Imports System.IO
Imports System.Data.OleDb
Public Class frmUpload
Dim myConnectionString As String = "server=ADMIN-TIA-NB\SQLEXPRESS;uid=sa;pwd=1234;database=tmp;"
Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)
Private Sub btupload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btupload.Click
Dim csvInputFile As String = "C:\logfile\new3.csv"
Dim cmd As SqlCommand = myConnection.CreateCommand()
Dim dt As New DataTable()
Dim line As String = Nothing
Dim i As Integer = 0
Using sr As StreamReader = File.OpenText(csvInputFile)
line = sr.ReadLine()
Do While line IsNot Nothing
Dim data() As String = line.Split(","c)
If data.Length > 0 Then
If i = 0 Then
For Each item In data
dt.Columns.Add(New DataColumn())
Next item
i = 1
End If
Dim row As DataRow = dt.NewRow()
row.ItemArray = data
dt.Rows.Add(row)
End If
line = sr.ReadLine()
dgv1.DataSource = dt
Loop
End Using
myConnection.Open()
Dim bc As New SqlBulkCopy(myConnection)
MsgBox(dt.Rows.Count)
bc.BatchSize = dt.Rows.Count
bc.DestinationTableName = "Transactions_Analyzer"
bc.WriteToServer(dt) // ----<<error ตรงนี้ครับ
bc.Close()
myConnection.Close()
dgv1.DataSource = dt
End Sub
End Class
Tag : .NET, Ms SQL Server 2005, Win (Windows App), VB.NET