|
|
|
failed to convert parameter value from a string to a datetime ขึ้นแบบนี้แก้ยังไงครับ |
|
|
|
|
|
|
|
Code (C#)
Connection.connnectsql3();
SqlConnection conC = new SqlConnection(Connection.strcon3);
{
using (SqlCommand command1 = new SqlCommand())
{
command1.Connection = conC;
command1.CommandText = "INSERT INTO main_A_file_Tbank(save_date, coop_code, mem_id, cif_number, branch_code, Thai_name, Eng_name, cif_service_code, saving_no, acc_type, current_no, current_acc_type, card_no, status_flg, id_no, date_rec_card, flg_save_in_coop) VALUES (GETDATE(),'601', @mem_id, @cif_number, @branch_code, @Thai_name, @Eng_name, @cif_service_code, @saving_no, @acc_type, @current_no, @current_acc_type, @card_no, @status_flg, @id_no,GETDATE(), 'S')";
command1.Parameters.Add(new SqlParameter("@save_date", SqlDbType.DateTime));
command1.Parameters.Add(new SqlParameter("@coop_code", SqlDbType.VarChar));
command1.Parameters.Add(new SqlParameter("@mem_id", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@cif_number", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@branch_code", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@Thai_name", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@Eng_name", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@cif_service_code", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@saving_no", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@acc_type", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@current_no", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@current_acc_type", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@card_no", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@status_flg", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@id_no", SqlDbType.NVarChar));
command1.Parameters.Add(new SqlParameter("@date_rec_card", SqlDbType.Date));
command1.Parameters.Add(new SqlParameter("@flg_save_in_coop", SqlDbType.NVarChar));
conC.Open();
foreach (DataGridViewRow row in dataGridView1.Rows)
{
if (!row.IsNewRow)
{
command1.Parameters["@save_date"].Value = row.Cells[0].Value;
command1.Parameters["@coop_code"].Value = row.Cells[1].Value;
command1.Parameters["@mem_id"].Value = row.Cells[2].Value;
command1.Parameters["@cif_number"].Value = row.Cells[3].Value;
command1.Parameters["@branch_code"].Value = row.Cells[4].Value;
command1.Parameters["@Thai_name"].Value = row.Cells[5].Value;
command1.Parameters["@Eng_name"].Value = row.Cells[6].Value;
command1.Parameters["@cif_service_code"].Value = row.Cells[7].Value;
command1.Parameters["@saving_no"].Value = row.Cells[8].Value;
command1.Parameters["@acc_type"].Value = row.Cells[9].Value;
command1.Parameters["@current_no"].Value = row.Cells[10].Value;
command1.Parameters["@current_acc_type"].Value = row.Cells[11].Value;
command1.Parameters["@card_no"].Value = row.Cells[12].Value;
command1.Parameters["@status_flg"].Value = row.Cells[13].Value;
command1.Parameters["@id_no"].Value = row.Cells[14].Value;
command1.Parameters["@date_rec_card"].Value = row.Cells[15].Value;
command1.Parameters["@flg_save_in_coop"].Value = row.Cells[16].Value;
command1.ExecuteNonQuery();
}
}
AutoClosingMessageBox.Show("Send to A_File_Tbank", "Success", 2000);
conC.Close();
dataGridView1.Columns.Clear();
dataGridView1.Refresh();
}
}
โค้ดที่เขียน ติด error failed to convert parameter value from a string to a datetime ต้องแก้ยังไงครับ
Tag : .NET, Win (Windows App), C#
|
|
|
|
|
|
Date :
2017-09-14 10:30:56 |
By :
darkgolfman0 |
View :
1135 |
Reply :
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
command1.Parameters["@save_date"].Value = Convert.ToDateTime(row.Cells[0].Value);
|
|
|
|
|
Date :
2017-09-14 10:36:26 |
By :
OOP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วรูปแบบวันที่เป้นยังไงครับ ขอดูหน่อย
|
|
|
|
|
Date :
2017-09-14 11:24:57 |
By :
OOP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะเอาข้อมูลที่โชว์ ใน gridview เข้าไปใน base
ฟิลที่อยู่ใน base
|
|
|
|
|
Date :
2017-09-14 11:44:18 |
By :
darkgolfman0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
วันที่ ที่โชว์ใน base ประมาณนี้ครับ
|
|
|
|
|
Date :
2017-09-14 11:46:06 |
By :
darkgolfman0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันจะทำได้ไงอะครับ ก็มันไม่ใช่วันที่อะ 00000157
|
|
|
|
|
Date :
2017-09-14 11:46:22 |
By :
OOP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้ครับ ตัดออกไปเลยครับ ไม่ต้องเอามาใส่
|
|
|
|
|
Date :
2017-09-14 13:20:05 |
By :
OOP |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|