alexa-tracking

Store Procedure

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/53ab789f0e8b4605200000db/store-procedure
Smile 
Store Procedure
Teman-temanku, saya mempunyai sebuah method seperti ini.

Code:

axCZKEM1.ReadAllUserID(iMachineNumber);
while (axCZKEM1.SSR_GetAllUserInfo(iMachineNumber, out sdwEnrollNumber, out sName, out sPassword, out iPrivilege, out bEnabled)) {
Dt = new DataTable();
StrSQL = "select * from [MsEmployee] " + System.Environment.NewLine +
"where [EmployeeID] = " + sdwEnrollNumber + "";
if (clglobal.DBType == "SQL Server") {
cldbSQL.sqlSelectReturnDt(StrSQL, Dt);
}

if (Dt.Rows.Count > 0) {
if (Convert.ToString(Dt.Rows[0]["EmployeeName"]) != sName) {
StrSQLUser += "update [MsEmployee] set " + System.Environment.NewLine +
"[EmployeeName]='" + sName + "'" + System.Environment.NewLine +
"[EditBy]='" + MasterForm.UserName + "', " + System.Environment.NewLine +
"[EditDate]=GetDate() " + System.Environment.NewLine +
"where [EmployeeID]=" + sdwEnrollNumber + "";
}
} else {
StrSQLUser += "insert into [MsEmployee]([EmployeeID], [EmployeeName], [CreateBy], [CreateDate]) " + System.Environment.NewLine +
"values(" + sdwEnrollNumber + ", '" + sName + "', '" + MasterForm.UserName + "', GetDate()) " + System.Environment.NewLine;
}
}

if (StrSQLUser != "") {
if (cldbSQL.SqlExecuteQuery(StrSQLUser) == 1) {
clglobal.ShowMessage("Success synchronize user.");
} else {
clglobal.ShowMessage("Fail synchronize user!");
}
} else {
clglobal.ShowMessage("Already the most recent data.");
}
} else {
clglobal.ShowMessage("Please connect the device first!");
return;
}



saya ingin merubah method diatas, menggunakan storeprocedure, dimana saya ingin mengeksekusi query query yang dihasilkan tersebut dalam 1 kali eksekusi, apabila ada 1 query gagal, maka harus digagalkan semuanya. Saya sudah mencari-cari jawaban di google ternyata tidak sesuai dengan keinginan saya tersebut.

Jawaban yang sesuai dengan pertanyaan saya ini, saya akan memberikan cendol kepada teman2.

Trims
coba search tentang TRANSACTION
^
^
kalah cepat emoticon-Malu