|
|
|
เกี่ยวกับ try catch อยากทราบวิธี Debug sql add parameter to StoredProcedure |
|
|
|
|
|
|
|
ขอทราบวิธี debug หน่อยครับ เหมือนมันไม่ส่งไปยัง store เพราะลอง console.writeline(TEST) ดูแล้ว ก้ไม่ขึ้น แล้วCatch ก็ไม่ขึ้นเช่นกัน จึงอยากทราบวิธี หาError ครับ
Code (C#)
using (SqlCommand empCommand = new SqlCommand("dbo.Pkinouttran_insert_member", dbConnection))
{
empCommand.CommandType = CommandType.StoredProcedure;
empCommand.Parameters.Add("@inouttran_id", SqlDbType.NVarChar).Value = inouttran_id;
// empCommand.Parameters.Add("@scr_no", SqlDbType.NVarChar).Value = (long)data[12 + i * 70 + 44] * 256 * 256 * 256 + (long)data[12 + i * 70 + 45] * 256 * 256 + (long)data[12 + i * 70 + 46] * 256 + (long)data[12 + i * 70 + 47];
int srcNo = data[12 + i * 70 + 44] * 256 * 256 * 256 + data[12 + i * 70 + 45] * 256 * 256 + data[12 + i * 70 + 46] * 256 + data[12 + i * 70 + 47];
empCommand.Parameters.Add("@cscmain_id", SqlDbType.NVarChar).Value = getPkcard.Get_CscMain_ID(srcNo);
empCommand.Parameters.Add("@rabbit_id", SqlDbType.NVarChar).Value = getPkcard.Get_Rabbit_ID(srcNo);
empCommand.Parameters.Add("@loc_id", SqlDbType.Int).Value = "1";
empCommand.Parameters.Add("@equip_id", SqlDbType.Int).Value = data[12 + i * 70 + 48];
dateIN = new DateTime(2000 + data[12 + i * 70 + 9], data[12 + i * 70 + 8], data[12 + i * 70 + 7], data[12 + i * 70 + 6], data[12 + i * 70 + 5], data[12 + i * 70 + 4]);
empCommand.Parameters.Add("@indate", SqlDbType.DateTime).Value = dateIN;
empCommand.Parameters.Add("@datein1", SqlDbType.DateTime).Value = dateIN.ToShortTimeString();
empCommand.Parameters.Add("@timein1", SqlDbType.Time).Value = dateIN.ToString("HH:mm:ss");
empCommand.Parameters.Add("@picin1", SqlDbType.NVarChar).Value = Name_Photo;
empCommand.Parameters.Add("@custno", SqlDbType.NVarChar).Value = getPkcard.Get_CustNo(srcNo);
empCommand.Parameters.Add("@typecard", SqlDbType.Int).Value = getPkcard.Get_TypeCard(srcNo);
empCommand.Parameters.Add("@lastloc_id", SqlDbType.Int).Value = data[12 + i * 70 + 48];
empCommand.Parameters.Add("@carid", SqlDbType.NVarChar).Value = getPkcard.Get_CarID(srcNo);
empCommand.Parameters.Add("@Zuser", SqlDbType.NVarChar).Value = "";
empCommand.Parameters.Add("@sf", SqlDbType.NVarChar).Value = "";
empCommand.Parameters.Add("@last_upd", SqlDbType.NVarChar).Value = "";
try
{
Console.WriteLine("TEST");
empCommand.ExecuteNonQuery();
getPkcard.UpdateStatus_PkCard(Scr_No, 1);
}
catch (SqlException ex) // This will catch all SQL exceptions
{
Console.WriteLine(("Execute exception issue: " + ex));
}
Tag : Ms SQL Server 2012, C#, VS 2012 (.NET 4.x)
|
|
|
|
|
|
Date :
2017-03-22 09:33:55 |
By :
bankzaclub |
View :
771 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
try
{
empCommand.CommandType = CommandType.StoredProcedure;
empCommand.Parameters.Add("@inouttran_id", SqlDbType.NVarChar).Value = inouttran_id;
// empCommand.Parameters.Add("@scr_no", SqlDbType.NVarChar).Value = (long)data[12 + i * 70 + 44] * 256 * 256 * 256 + (long)data[12 + i * 70 + 45] * 256 * 256 + (long)data[12 + i * 70 + 46] * 256 + (long)data[12 + i * 70 + 47];
int srcNo = data[12 + i * 70 + 44] * 256 * 256 * 256 + data[12 + i * 70 + 45] * 256 * 256 + data[12 + i * 70 + 46] * 256 + data[12 + i * 70 + 47];
empCommand.Parameters.Add("@cscmain_id", SqlDbType.NVarChar).Value = getPkcard.Get_CscMain_ID(srcNo);
empCommand.Parameters.Add("@rabbit_id", SqlDbType.NVarChar).Value = getPkcard.Get_Rabbit_ID(srcNo);
empCommand.Parameters.Add("@loc_id", SqlDbType.Int).Value = "1";
empCommand.Parameters.Add("@equip_id", SqlDbType.Int).Value = data[12 + i * 70 + 48];
dateIN = new DateTime(2000 + data[12 + i * 70 + 9], data[12 + i * 70 + 8], data[12 + i * 70 + 7], data[12 + i * 70 + 6], data[12 + i * 70 + 5], data[12 + i * 70 + 4]);
empCommand.Parameters.Add("@indate", SqlDbType.DateTime).Value = dateIN;
empCommand.Parameters.Add("@datein1", SqlDbType.DateTime).Value = dateIN.ToShortTimeString();
empCommand.Parameters.Add("@timein1", SqlDbType.Time).Value = dateIN.ToString("HH:mm:ss");
empCommand.Parameters.Add("@picin1", SqlDbType.NVarChar).Value = Name_Photo;
empCommand.Parameters.Add("@custno", SqlDbType.NVarChar).Value = getPkcard.Get_CustNo(srcNo);
empCommand.Parameters.Add("@typecard", SqlDbType.Int).Value = getPkcard.Get_TypeCard(srcNo);
empCommand.Parameters.Add("@lastloc_id", SqlDbType.Int).Value = data[12 + i * 70 + 48];
empCommand.Parameters.Add("@carid", SqlDbType.NVarChar).Value = getPkcard.Get_CarID(srcNo);
empCommand.Parameters.Add("@Zuser", SqlDbType.NVarChar).Value = "";
empCommand.Parameters.Add("@sf", SqlDbType.NVarChar).Value = "";
empCommand.Parameters.Add("@last_upd", SqlDbType.NVarChar).Value = "";
Console.WriteLine("TEST");
empCommand.ExecuteNonQuery();
getPkcard.UpdateStatus_PkCard(Scr_No, 1);
}
catch (SqlException ex) // This will catch all SQL exceptions
{
Console.WriteLine(("Execute exception issue: " + ex));
}
ครอบ try ทั้งหมดเลยครับ
|
|
|
|
|
Date :
2017-03-22 10:18:20 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|