|
![](/images/resource/spacer.gif) |
|
การ insert ข้อมูลวันที่ใน sql server ที่เป็น datetime..The conversion of a char data type to a datetime data type resulted |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
คือผมเขียนคำสั่งแบบนี้อ่ะครับ
sql = String.Format("INSERT INTO IDCard( IDNum,IDName,DateSave) VALUES('{0}','{1}','{2}')"
, txtNum.Text, txtIDCard.Text, txtDate.Text)
ds = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, sql)
แล้วพอบันทึกมันขึ้นว่า
The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
The statement has been terminated.
เออเร่อแบบนี้อ่ะครับ ซึ่งมันน่าจะบันทุกเป็นแบบ string เราควรแปลงเป็น datetime ยังไงอ่ะครับ ช่วยทีครับผม
Tag : ASP, Web (ASP.NET)
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2014-03-13 15:17:37 |
By :
Patoo |
View :
4670 |
Reply :
2 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ปรับข้อมูล Text ให้เป็นในรูปแบบ yyyy-mm-dd ถ้าไม่ได้อาจต้องตรวจสอบว่า format ของ sql server เก็บในรูปแบบใดครับ
แต่ถ้าไม่ได้ปรับแต่งอะไรมากทั่วๆไปจะเป็น mm/dd/yyyy ครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2014-03-13 16:21:24 |
By :
heartbeat |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ขอบคุณคราบบบบบบบบบ ![](/images/bbcode/lol.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2014-03-14 10:06:38 |
By :
Patoo |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 04
|