I'm using this code.
DataTable dst = new DataTable();
dst = (DataTable)dataGridView1.DataSource;
this.dataGridView1.Columns[2].ValueType = typeof(DateTime);
this.dataGridView1.Columns[6].ValueType = typeof(DateTime);
dst.TableName = "DataGridviewTpXml";
dst.WriteXml("\\HomeCareVisit.xml", true);
MessageBox.Show("downloaded to file");
to write from datagridview to XML and this code
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
VisitRefNo = ds.Tables[0].Rows[i].ItemArray[0].ToString();
PatientNo = Convert.ToInt32(ds.Tables[0].Rows[i].ItemArray[1]);
ScheduledDateTime = Convert.ToDateTime(ds.Tables[0].Rows[i].ItemArray[2]);
TreatmentInstructions = ds.Tables[0].Rows[i].ItemArray[3].ToString();
MedicalStaffID = Convert.ToInt32(ds.Tables[0].Rows[i].ItemArray[4]);
Priority = ds.Tables[0].Rows[i].ItemArray[5].ToString();
ActualVisitDateTime = Convert.ToDateTime(ds.Tables[0].Rows[i].ItemArray[6]);
TreatmentProvided = ds.Tables[0].Rows[i].ItemArray[7].ToString();
Prescription = ds.Tables[0].Rows[i].ItemArray[8].ToString();
AdvisoryNotes = ds.Tables[0].Rows[i].ItemArray[9].ToString();
FurtherVisitRequired = Convert.ToBoolean(ds.Tables[0].Rows[i].ItemArray[10]);
FurtherVisitRequired = Convert.ToBoolean(ds.Tables[0].Rows[i].ItemArray[10]);
sql = "SET IDENTITY_INSERT HomeCareVisit ON update HomeCareVisit set PatientNo='" + PatientNo + "',ScheduledDateTime='" + ScheduledDateTime + "',TreatmentInstructions='" + TreatmentInstructions + "', MedicalStaffID='" + MedicalStaffID + "', Priority='" + Priority + "',ActualVisitDateTime='" + ActualVisitDateTime + "',TreatmentProvided='" + TreatmentProvided + "',Prescription='" + Prescription + "',AdvisoryNotes='" + AdvisoryNotes + "',FurtherVisitRequired='" + (FurtherVisitRequired ? "1" : "0") + "'where VisitRefNo='" + VisitRefNo + "';";
to read from xml to SQL. However it is giving me the following exception
"The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated." How can this be fixed?
The application I'm trying to make stores certain details including timedate's.
IDE being used visual studio language ADO.Net c# server SQL server.
any help would be greatly appreciated, Thank you.
ADDITIONAL DETAIL I'm using the datagridview to add/edit and delete records. If that was unclear, i hope that little bit extra information helps?