Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.
มันเกิดตอนที่มีข้อมูลเยอะๆอะค่ะ คือใช้ odbc ติดต่อกับ access แล้วเอามาใช้ใน .net อีกทีค่ะ
อย่างนี้ต้องแก้ไขด้วยวิธีไหนหรอคะ
sql = "SELECT No,Name,Address,Tel,Email,BirthDay FROM [Employee Register]"
Dim adapter = New OdbcDataAdapter(sql, ODconn)
Dim DView As DataView
Dim myDataSet As New DataSet("Emp")
adapter.Fill(myDataSet, "Emp")
DView = myDataSet.Tables("Emp").DefaultView
Dim drowview As DataRowView
For Each drowview In DView
Dim No = drowview.Item("No")
Dim Name = drowview.Item("Name")
Dim Address = drowview.Item("Address")
Dim Tel = drowview.Item("Tel")
Dim Email = drowview.Item("Email")
Dim BirthDay = drowview.Item("BirthDay")
sql2 = "Insert Into Employee (No,Name,Address,Tel,Email,BirthDay)values(@No,@Name,@Address,@Tel,@Email,Convert(DateTime,@BirthDay, 103)) "
cmd = New SqlCommand(sql2, Conn)
cmd.Parameters.Add("@No", SqlDbType.NVarChar).Value = No
cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = Name
cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = Address
cmd.Parameters.Add("@Tel", SqlDbType.NVarChar).Value = Tel
cmd.Parameters.Add("@Email", SqlDbType.NVarChar).Value = Email
cmd.Parameters.Add("@BirthDay", SqlDbType.NVarChar).Value = BirthDay
Conn.Open()
cmd.ExecuteNonQuery()
Conn.Close()
Next