Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Database Trouble (ASP)

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,3109
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Database Trouble (ASP)
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Database Trouble (ASP) - 5/24/2005 6:40:24 PM   
  trachelle_16

 

Posts: 1
Score: 0
Joined: 5/24/2005
From: Philippines
Status: offline
Hello, I am encountering some problems regarding the output of the wep page. My page has a textfield that displays all the records. If you try to click the add button it will enable the administrator to add a new record and once it is saved it will be passed onto the textfield, the output should look like this for example: Name|Telephone|Address. The problem is after adding a new record it should include another | to seperate another data and add letter "N", meaning it is a new record. The output should look this this for example: Name|Telephone|Address|N. Also I have included ¦ to separate records example: Name|Telephone|Address¦Name2|Telephone2|Address2, while for the edit button my problem is, it has to output letter "O" meaning it is an old record the ouptput should look like this:Name|Telephone|Address|O, that will also include letter "U" if the administrator edited the record meaning the record had been updated the output should look like this:Name|Telephone|Address|O|U, and all this output should appear at the textfield after clicking save. The purpose of the program is to know whether the record is an old or new record and whether it is updated or not. Note: only updated records will have an output with letter "U".

Please Help

MY CODES

group.asp
<%@ language="vbscript"%>
<%
const groupIDPos = 0
const groupNamePos = 1
const groupInitPos = 2
const groupRemarksPos = 3
const groupStatusPos = 4

connStr = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa; password=Password;Initial Catalog=COMET;Data Source=10.28.85.14"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connStr

'Instantiate a Recordset object
Set groupData = Server.CreateObject("ADODB.Recordset")

' Open a recordset using the Open method and use the connection established by the Connection object
strSQL = "SELECT [WorkGroupID],[WorkGroupName],[WorkGroupInitial],[Remarks],[Status] FROM WorkGroupTbl ORDER BY [WorkGroupID] DESC"
groupData.Open strSQL, conn

groupMainStr = ""
do until groupData.eof
For Each groupDataFld In groupData.Fields
groupMainStr = groupMainStr & groupDataFld & "|"
Next
groupMainStr = Mid(groupMainStr,1,len(groupMainStr)-1) & "¦"
groupData.MoveNext
loop
groupData.Close

if (groupMainStr <> "") then
groupMainStr = Mid(groupMainStr,1,len(groupMainStr)-1)
else
groupMainStr = "||||"
end if
conn.Close

'Response.Write groupMainStr
%>

<html>
<head>
<title>Administration Group</title>
<link rel="stylesheet" type="text/css" href="../Main/main.css">
<script language="javascript" type="text/javascript" src="../Scripts/navigation.js"></script>
</head>
<script language="javascript">
function trim(str)
{
var retValue = str;
if (retValue.length == 0)
{
return "";
}

ch = retValue.substring(0,1);

while (ch == " ")
{
retValue = retValue.substring(1,retValue.length);
ch = retValue.substring(0,1);
}

ch = retValue.charAt(retValue.length - 1);
while (ch == " ")
{
retValue = retValue.substring(0,retValue.length - 1);
ch = retValue.charAt(retValue.length - 1);
}
return retValue;
}

function getRecords(comparisonStr, recordArrayStr, findIndex)
{
returnStr = "";
if (recordArrayStr.indexOf("¦") != -1)
{
recordArray = recordArrayStr.split("¦");
for (ctr=0;ctr<recordArray.length;ctr++)
{
if (recordArray[ctr] != "")
{
fieldArray = recordArray[ctr].split("|");
if (comparisonStr == fieldArray[findIndex])
{
returnStr += recordArray[ctr] + "¦";
}
}
}
}
else
{
fieldArray = recordArrayStr.split("|");
if (comparisonStr == fieldArray[findIndex])
{
returnStr += recordArrayStr + "¦";
}
}
returnStr = returnStr.substring(0,returnStr.length-1);

return returnStr;
}

function btnAddItm_onmouseover()
{
if (!groupDataLayoutForm.btnAdd.isDisabled) groupDataLayoutForm.btnAdd.focus();
}

function btnAdd_onClick()
{
dataStr = "||||";

result = window.showModalDialog("./groupDTL.asp",dataStr,"dialogWidth=500px;dialogHeight:500px");
if (result != "")
{
if (groupDataSubmitForm.groupDetailTxt.value.indexOf("||||") == -1)
groupDataSubmitForm.groupDetailTxt.value += "¦" + result;
else
groupDataSubmitForm.groupDetailTxt.value = result;
putDataInForm(groupDataSubmitForm.groupDetailTxt.value);
}
}

function openDetail(groupIDNum,groupNameNum)
{
dataStr = "";
if ((groupIDNum.indexOf("null") != 0) && (groupIDNum != ""))
{
dataStr = getRecords(groupIDNum,groupDataSubmitForm.groupDetailTxt.value,<%=groupIDPos%>);
}
else if ((groupNameNum.indexOf("null") != 0) && (groupNameNum != ""))
{
dataStr = getRecords(groupNameNum,groupDataSubmitForm.groupDetailTxt.value,<%=groupNamePos%>);
}
// alert(dataStr);

if (dataStr != "")
{
result = window.showModalDialog("./groupDTL.asp",dataStr,"dialogWidth=500px;dialogHeight:500px");

if (result != "")
{
if (result != dataStr)
{
resultArr = result.split("|");
mainStr = groupDataSubmitForm.groupDetailTxt.value.split("¦");
groupDataSubmitForm.groupDetailTxt.value = "";
for (i=0;i<mainStr.length;i++)
{
mainStrDtl = mainStr.split("|");
if (mainStrDtl[<%=groupIDPos%>] != groupIDNum)
{
groupDataSubmitForm.groupDetailTxt.value += mainStr + "¦";
}
else
{
groupDataSubmitForm.groupDetailTxt.value += result + "¦";
}
}
groupDataSubmitForm.groupDetailTxt.value = groupDataSubmitForm.groupDetailTxt.value.substring(0,groupDataSubmitForm.groupDetailTxt.value.length-1);
}
putDataInForm(groupDataSubmitForm.groupDetailTxt.value);
}
}
}

function putDataInForm(dataToPlot)
{
if (dataToPlot.indexOf("||||") != -1)
dataToPlot = "";
totalAmount = 0;
if (dataToPlot == "")
{
totalRecords = 0;
}
else
{
if (dataToPlot.indexOf("¦") == -1)
{
recordToForm = dataToPlot;
totalRecords = 1;
}
else
{
recordToForm = dataToPlot.split("¦");
totalRecords = recordToForm.length;
}
}

layout = "";
layout += "<table border=1 cellpadding=0 cellspacing=0 width=745>";
layout += " <tr bgcolor=\"#e0e0e0\">";
// layout += " <td width=\"45\" align=\"middle\"> </td>";
layout += " <td width=\"230\" align=\"center\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
layout += " <b>GROUP NAME</b>";
layout += " </font>";
layout += " </td>";
layout += " <td width=\"130\" align=\"center\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
layout += " <b>GROUP INITIAL</b>";
layout += " </font>";
layout += " </td>";
layout += " <td width=\"300\" align=\"center\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
layout += " <b>REMARKS</b>";
layout += " </font>";
layout += " </td>";
layout += " <td width=\"90\" align=\"center\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
layout += " <b>STATUS</b>";
layout += " </font>";
layout += " </td>";
layout += " </tr>";

if (totalRecords != 0)
{
for (i=0;i<totalRecords;i++)
{
if (totalRecords == 1)
{
dataToForm = recordToForm.split("|");
}
else
{
dataToForm = recordToForm.split("|");
}

layout += "<tr>";
/* layout += " <td width=45 align=center>";
layout += " <img onclick='return deleteItem(this.id)' id=" + dataToForm[0] + "|" + dataToForm[1] + "Del alt='Delete Item' src='../images/Delete.gif'></img>";
layout += " </td>";
*/
/* Comprises of the data to be put on the form */
layout += " <td width=\"230\" align=\"left\" onclick=\"return openDetail('" + dataToForm[<%=groupIDPos%>] + "','" + dataToForm[<%=groupNamePos%>] + "');\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\" color=\"#000000\"" +
" onmouseover=\"this.style.color='blue';this.style.fontWeight='bold'\"" +
" onmouseout=\"this.style.color='#000000';this.style.fontWeight='normal'\">";
// layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=1> ";
layout += "  " + dataToForm[<%=groupNamePos%>];
layout += " </font>";
layout += " </td>";
layout += " <td width=\"130\" align=\"left\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=1> ";
layout += "  " + dataToForm[<%=groupInitPos%>];
layout += " </font>";
layout += " </td>";
layout += " <td width=\"300\" align=\"left\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=1> ";
layout += "  " + dataToForm[<%=groupRemarksPos%>];
layout += " </font>";
layout += " </td>";
layout += " <td width=\"90\" align=\"left\">";
layout += " <font face=\"Verdana, Arial, Helvetica, sans-serif\" size=1> ";
if (dataToForm[<%=groupStatusPos%>].indexOf("True") != -1)
layout += "  Active";
else
layout += "  Inactive";
layout += " </font>";
layout += " </td>";
layout += "</tr>";
}
}

layout += "</table>";
groupDetailsDiv.innerHTML = layout;
}

function btnSave_onclick()
{
// alert(groupDataSubmitForm.groupDetailTxt.value);
if (groupDataSubmitForm.groupDetailTxt.value == "||||")
groupDataSubmitForm.groupDetailTxt.value = "";
groupDataSubmitForm.action = "../Main/groupProcess.asp";
groupDataSubmitForm.submit();
groupDataSubmitForm.clearAttributes();
}

function btnSave_onmouseover()
{
if (!groupDataLayoutForm.saveBtn.disabled) groupDataLayoutForm.saveBtn.focus();
}

function btnCancel_onclick()
{
window.location.reload(false);
}

function btnCancel_onmouseover()
{
if (!groupDataLayoutForm.cancelBtn.disabled) groupDataLayoutForm.cancelBtn.focus();
}
</script>
<body onload="init();">
<!--#include file = "../Scripts/CommonFunctions.asp"-->
<%CreatePageHeader%>
<br></br>
<form id="groupDataSubmitForm" name="groupDataSubmitForm" method="post">
<table width="750" border="0" height="20" cellspacing="0" cellpadding="0" style="left: 9px; TOP: 15px" align="center">
<tr>
<td>
<input name="groupDetailTxt" id="groupDetailTxt" style="visibility:visible; width:15px; height:22px"
size=40 value="<%=groupMainStr%>"></input>
</td>
</tr>
</table>
</form>
<form id="groupDataLayoutForm" name="groupDataLayoutForm">
<table border="0" width="750" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="3">
<input type="button" name="btnAdd" id="btnAdd" value="Add" style="width:100px"
onclick="return btnAdd_onClick();" onmouseover="return btnAddItm_onmouseover();"></input>
</td>
</tr>
<tr>
<td>
<div name="groupDetailsDiv" id="groupDetailsDiv">
<table border="1" width="745" align="center" cellpadding="0" cellspacing="0">
<tr bgcolor="#e0e0e0">
<td width="45" height="22" align="middle"> </td>
<td width="230" align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<b>GROUP NAME</b>
</font>
</td>
<td width="130" align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<b>GROUP INITIAL</b>
</font>
</td>
<td width="300" align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<b>REMARKS</b>
</font>
</td>
<td width="90" align="center">
<font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000000">
<b>STATUS</b>
</font>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<script>
putDataInForm(groupDataSubmitForm.groupDetailTxt.value);
</script>
<p>
<center>
<input type="button" value="Save" id="saveBtn" name="saveBtn" style="width:60px" onmouseover="btnSave_onmouseover();" onclick="btnSave_onclick();">
<input type="button" value="Cancel" id="cancelBtn" name="cancelBtn" style="width:60px" onmouseover="btnCancel_onmouseover();" onclick="btnCancel_onclick();">
</center>
</form>
</body>
</html>
______________________________________________________________________
groupDTL.asp
<%@ Language=VBScript %>
<%
const groupIDPos = 0
const groupNamePos = 1
const groupInitPos = 2
const groupRemarksPos = 3
const groupStatusPos = 4
%>
<html>
<head>
<script language="javascript" type="text/javascript" src="../Scripts/navigation.js"></script>
</head>
<script language="javascript">
function window_onload()
{
groupDetailSubmitForm.groupDetail.value = window.dialogArguments;
// alert(groupDetallSubmitForm.groupDetail.value);
loadData();
}

function window_onunload()
{
if (groupDetailSubmitForm.groupDetail.value != window.dialogArguments)
{
window.returnValue = groupDetailSubmitForm.groupDetail.value;
}
else
{
window.returnValue = "";
}
}

function loadData()
{
dataStr = window.dialogArguments;
if (dataStr != "||||")
{
comparisonStr = dataStr.split("|");

groupDisplayData.strGroupName.value = comparisonStr[<%=groupNamePos%>];
groupDisplayData.strGroupInit.value = comparisonStr[<%=groupInitPos%>];
groupDisplayData.strRemarks.value = comparisonStr[<%=groupRemarksPos%>];
if (comparisonStr[<%=groupStatusPos%>].indexOf("True") != -1)
groupDisplayData.acInacInp.selectedIndex = 0;
else if (comparisonStr[<%=groupStatusPos%>].indexOf("False"))
groupDisplayData.acInacInp.selectedIndex = 1;
}
else
{
groupDisplayData.strGroupName.readOnly = false;
groupDisplayData.strGroupInit.readOnly = false;
groupDisplayData.strRemarks.readOnly = false;
groupDisplayData.acInacInp.disabled = false;
groupDisplayData.btnEdit.value = "Save";
}
}
/*
function updateDataArrayRecord(targetPos,inputData,targetArrayObj)
{
var newDataArray = "";

origDataArray = targetArrayObj.value.split("|");
for (ctr = 0;ctr < origDataArray.length; ctr++)
{
if (ctr == targetPos)
{
newDataArray += inputData + "|";
}
else
{
newDataArray += origDataArray[ctr] + "|";
}
}
targetArrayObj.value = newDataArray.substring(0,newDataArray.length-1);
}
*/
function btnEdit_onClick()
{
if (groupDisplayData.strGroupName.readOnly == true)
{
groupDisplayData.strGroupName.readOnly = false;
groupDisplayData.strGroupInit.readOnly = false;
groupDisplayData.strRemarks.readOnly = false;
groupDisplayData.acInacInp.disabled = false;
groupDisplayData.btnEdit.value = "Save";
}
else
{
comparisonStr = groupDetailSubmitForm.groupDetail.value.split("|");
if (groupDisplayData.strGroupName.value != comparisonStr[<%=groupNamePos%>])
{
updateDataArrayRecord(<%=groupNamePos%>,groupDisplayData.strGroupName.value,groupDetailSubmitForm.groupDetail);
}
if (groupDisplayData.strGroupInit.value != comparisonStr[<%=groupInitPos%>])
{
updateDataArrayRecord(<%=groupInitPos%>,groupDisplayData.strGroupInit.value,groupDetailSubmitForm.groupDetail);
}
if (groupDisplayData.strRemarks.value != comparisonStr[<%=groupRemarksPos%>])
{
updateDataArrayRecord(<%=groupRemarksPos%>,groupDisplayData.strRemarks.value,groupDetailSubmitForm.groupDetail);
}
if (groupDisplayData.acInacInp.selectedIndex == 0)
statStr = "True";
else
statStr = "False";
updateDataArrayRecord(<%=groupStatusPos%>,statStr,groupDetailSubmitForm.groupDetail);
window.close();
}
}

function btnClose_onClick()
{
window.close();
}

function groupName_onkeypress()
{
if (groupDisplayData.strGroupName.value.length > 20)
return false;
}

function groupInit_onkeypress()
{
if (groupDisplayData.strGroupInit.value.length > 10)
return false;
}

function remarks_onkeypress()
{
if (groupDisplayData.strRemarks.value.length > 100)
return false;
}
</script>
<body onload="return window_onload();" onunload="return window_onunload();" bgcolor="#cccccc">
<form name="groupDetailSubmitForm" id="groupDetailSubmitForm" method="post">
<input name="groupDetail" id="groupDetail" style="visibility:visible; width:15px; height:22px"
size="40"></input>
</form>

<form name="groupDisplayData" id="groupDisplayData" method="post">
<center>
<table width="420">
<tr>
<td align="right" width="100">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">GROUP NAME</font></b>
</td>
<td align="center" width="310">
<input type="text" name="strGroupName" id="strGroupName" size="10" readonly
style="width:300px;font-family:verdana;font-size:10pt"
onkeypress="return groupName_onkeypress();"></input>
</td>
</tr>
<tr>
<td align="right" width="100">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">GROUP INITIAL</font></b>
</td>
<td align="center" width="310">
<input type="text" name="strGroupInit" id="strGroupInit" size="100" readonly
style="width:300px;font-family:verdana;font-size:10pt"
onkeypress="return groupInit_onkeypress();"></input>
</td>
</tr>
<tr>
<td align="right" width="100">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">REMARKS</font></b>
</td>
<td align="center" width="310">
<input type="text" name="strRemarks" id="strRemarks" size="30" readonly
style="width:300px;font-family:verdana;font-size:10pt"
onkeypress="return remarks_onkeypress();"></input>
</td>
</tr>
<tr>
<td align="right" width="100">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="1">STATUS</font></b>
</td>
<td align="center" width="310">
<select style="width:300" name="acInacInp" id="acInacInp" disabled>
<option value="AcOpt">Active</option>
<option value="InactOpt">Inactive</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">

</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="button" value="Edit" name="btnEdit" style="WIDTH: 60px" onclick="return btnEdit_onClick()">
<input type="button" value="Close" name="btnClose" style="WIDTH: 60px" onclick="return btnClose_onClick()">
</td>
</tr>
</table>
</center>
</form>
</body>
</html>
______________________________________________________________________groupProcess.asp
<%@ language="vbscript"%>
<%
const groupIDPos = 0
const groupNamePos = 1
const groupInitPos = 2
const groupRemarksPos = 3
const groupStatusPos = 4

groupDetailTxt = Request.Form("groupDetailTxt")
connStr = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa; password=Password;Initial Catalog=Comet;Data Source=10.28.85.14"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connStr

if (InStr(1,groupDetailTxt,"|") <> 0) then
if (InStr(1,groupDetailTxt,"'") <> 0) then
groupDetailTxt = Replace(groupDetailTxt,"'","''")
end if
if (InStr(1,groupDetailTxt,"¦") = 0) then
groupDetailDataArr = split(groupDetailTxt,"|")
if (groupDetailDataArr(groupIDPos) = "") then
tmpDateTimeArr = split(now," ")
tmpDateArr = split(tmpDateTimeArr(0),"/")
if (len(tmpDateArr(0)) < 2) then
tmpDateArr(0) = "0" & tmpDateArr(0)
end if
if (len(tmpDateArr(1)) < 2) then
tmpDateArr(1) = "0" & tmpDateArr(1)
end if

tmpTimeArr = split(tmpDateTimeArr(1),":")
if (len(tmpTimeArr(0)) < 2) then
tmpTimeArr(0) = "0" & tmpTimeArr(0)
end if
if (len(tmpTimeArr(1)) < 2) then
tmpTimeArr(1) = "0" & tmpTimeArr(1)
end if
if (len(tmpTimeArr(2)) < 2) then
tmpTimeArr(2) = "0" & tmpTimeArr(2)
end if
groupDetailDataArr(groupIDPos) = tmpDateArr(2) & tmpDateArr(0) & tmpDateArr(1) & tmpTimeArr(0) & tmpTimeArr(1) & tmpTimeArr(2)
if (InStr(1,prevgroupID,groupDetailDataArr(groupIDPos)) <> 0) then
idCtr = idCtr + 1
else
idCtr = 0
end if
groupDetailDataArr(groupIDPos) = groupDetailDataArr(groupIDPos) & idCtr
for j=0 to ubound(groupDetailDataArr) - 1
tmpInsertCmd = tmpInsertCmd & "'" & groupDetailDataArr(j) & "',"
next
if groupDetailDataArr(groupStatusPos) = "True" then
tmpInsertCmd = tmpInsertCmd & "1,"
else
tmpInsertCmd = tmpInsertCmd & "0,"
end if
cmdStr = "INSERT INTO WorkGroupTbl " & _
"([WorkGroupID],[WorkGroupName],[WorkGroupInitial],[Remarks],[Status]," & _
" [CreatedDate],[CreatedBy]) " & _
"VALUES (" & Mid(tmpInsertCmd,1,len(tmpInsertCmd)-1) & _
" ,'" & Now & "','jgcarballo')"
' Response.Write cmdStr
' Response.End
prevgroupID = groupDetailDataArr(groupIDPos)
else
if groupDetailDataArr(groupStatusPos) = "True" then
tmpInsertCmd = tmpInsertCmd & "1,"
else
tmpInsertCmd = tmpInsertCmd & "0,"
end if

cmdStr = "UPDATE WorkGroupTbl " & _
"SET [WorkGroupName] = '" & groupDetailDataArr(groupNamePos) & "', " & _
" [WorkGroupInitial] = '" & groupDetailDataArr(groupInitPos) & "', " & _
" [Remarks] = '" & groupDetailDataArr(groupRemarksPos) & "', " & _
" [Status] = " & tmpInsertCmd & " " & _
" [UpdatedBy] = 'jgcarballo', " & _
" [UpdatedDate] = '" & Now & "' " & _
"WHERE [WorkGroupID] = '" & groupDetailDataArr(groupIDPos) & "'"
'Response.Write cmdStr
' Response.End
end if
conn.Execute(cmdStr)
else
groupDetailArr = split(groupDetailTxt,"¦")
idCtr = 0
transCtr = 0
for i = 0 to ubound(groupDetailArr)
groupDetailDataArr = split(groupDetailArr(i),"|")
tmpInsertCmd = ""
' If there is no Site ID
if (groupDetailDataArr(groupIDPos) = "") then
tmpDateTimeArr = split(now," ")
tmpDateArr = split(tmpDateTimeArr(0),"/")
if (len(tmpDateArr(0)) < 2) then
tmpDateArr(0) = "0" & tmpDateArr(0)
end if
if (len(tmpDateArr(1)) < 2) then
tmpDateArr(1) = "0" & tmpDateArr(1)
end if

tmpTimeArr = split(tmpDateTimeArr(1),":")
if (len(tmpTimeArr(0)) < 2) then
tmpTimeArr(0) = "0" & tmpTimeArr(0)
end if
if (len(tmpTimeArr(1)) < 2) then
tmpTimeArr(1) = "0" & tmpTimeArr(1)
end if
if (len(tmpTimeArr(2)) < 2) then
tmpTimeArr(2) = "0" & tmpTimeArr(2)
end if
groupDetailDataArr(groupIDPos) = tmpDateArr(2) & tmpDateArr(0) & tmpDateArr(1) & tmpTimeArr(0) & tmpTimeArr(1) & tmpTimeArr(2)
if (InStr(1,prevgroupID,groupDetailDataArr(groupIDPos)) <> 0) then
idCtr = idCtr + 1
else
idCtr = 0
end if
groupDetailDataArr(groupIDPos) = groupDetailDataArr(groupIDPos) & idCtr
for j=0 to ubound(groupDetailDataArr) - 1
tmpInsertCmd = tmpInsertCmd & "'" & groupDetailDataArr(j) & "',"
next
if groupDetailDataArr(groupStatusPos) = "True" then
tmpInsertCmd = tmpInsertCmd & "1,"
else
tmpInsertCmd = tmpInsertCmd & "0,"
end if
cmdStr = "INSERT INTO WorkGroupTbl " & _
"([WorkGroupID],[WorkGroupName],[WorkGroupInitial],[Remarks],[Status]," & _
" [CreatedDate],[CreatedBy]) " & _
"VALUES (" & Mid(tmpInsertCmd,1,len(tmpInsertCmd)-1) & _
" ,'" & Now & "','jgcarballo')"
' Response.Write cmdStr
' Response.End
prevgroupID = groupDetailDataArr(groupIDPos)
else
if groupDetailDataArr(groupStatusPos) = "True" then
tmpInsertCmd = tmpInsertCmd & "1,"
else
tmpInsertCmd = tmpInsertCmd & "0,"
end if

cmdStr = "UPDATE WorkGroupTbl " & _
"SET [WorkGroupName] = '" & groupDetailDataArr(groupNamePos) & "', " & _
" [WorkGroupInitial] = '" & groupDetailDataArr(groupInitPos) & "', " & _
" [Remarks] = '" & groupDetailDataArr(groupRemarksPos) & "', " & _
" [Status] = " & tmpInsertCmd & " " & _
" [UpdatedBy] = 'jgcarballo', " & _
" [UpdatedDate] = '" & Now & "' " & _
"WHERE [WorkGroupID] = '" & groupDetailDataArr(groupIDPos) & "'"
' Response.Write cmdStr
' Response.End
end if
' Response.Write cmdStr
' Response.End
conn.Execute(cmdStr)
next
end if
'Response.End
else
if (len(groupDetailTxt) = 0) then
conn.Execute("DELETE FROM WorkGroupTbl")
else

end if
end if

conn.Close()
'Response.End
Response.Redirect "http://localhost/Comet/main/group.asp"
%>
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Database Trouble (ASP) Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts