|
|
|
ช่วยดูให้หน่อยครับว่าผิดต้องไหนครับ ลองแปลงมาจาก PHP อะครับ |
|
|
|
|
|
|
|
Code (ASP)
<body>
<%
'Check if user is logged in
if Session("name") = "" then
'If not, go to login page
Response.Redirect("login.asp")
else
'If, build page
%>
<!-- START PAGE SOURCE -->
<div class="main">
<div class="header">
<div class="header_resize">
<div class="logo">
<h1><a href="index.html">Loyalty Program <img src="images/pix1.jpg" width="58" height="58" /><small>put your slogan here</small></a></h1>
</div>
<div class="clr"></div>
<div class="menu_nav">
<ul>
<li><a href="Home.asp">Home</a></li>
<li><a href="Profile.asp">Profile</a></li>
<li class="active"><a href="InputData.asp">Input dAta</a></li>
<li><a href="blog.html">Report</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li><a href="logout.asp">Logout</a></li>
</ul>
</div>
<div class="clr">
</div><table width="970" border="0" bgcolor="#FFFFFF">
<tr>
<td width="970">
<%
Dim Conn,strSQL,objExec,i
BDate= Request.Form("bday")
DDate=Date()
SDCode = Request.Form("txtSDDealerCode")
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=L0820_WUTTISAA1;Database=OVCM;UID=ovcm;PWD=Ninekao9;"
for(i=1;i<=(int)(POST["hdnMaxLine"]);i++)
strSQL = ""
strSQL = strSQL &"INSERT INTO WLoyalty "
strSQL = strSQL &"(DocDate,SDCode,BFDealer,Product,QTY,UserCreate,CreateDate) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &" ('"&BDate&"','"&SDCode&"','"POST["Column1_".i]."','"POST["Column2_".i]."','"POST["Column3_".i]."','"&Session("name")&"','"&DDate&"')";
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
%>
<meta http-equiv="refresh" content="3;URL=Truck_AddProfile.asp">
<table width="900" height="69" border="0" align="center">
<tr>
<td width="882" height="32" align="center"></td>
</tr>
<tr>
<td height="31" align="center"> </td>
</tr>
</table>
<p>
<%
'Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End If
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
</p>
</tr>
</table></td>
</tr>
</table>
</div>
</div>
<div class="content">
<div class="content_resize">
<div class="clr"></div>
</div>
</div>
<div class="fbg">
<div class="fbg_resize">
<div class="clr">
</div>
</div>
</div>
<div class="footer">
<div class="footer_resize">
<p class="lf">Copyright © 2010 <a href="#">SiteName</a> - All Rights Reserved</p>
<p class="rf">Login</a> by <a href=""><%Response.write(Session("name"))%></a></p>
<div class="clr"></div>
</div>
</div>
</div>
<!-- END PAGE SOURCE -->
<div align=center>This template downloaded form <a href='http://all-free-download.com/free-website-templates/'>free website templates</a></div>
<% end if %>
</body>
Tag : ASP, Ms SQL Server 2005, Windows
|
|
|
|
|
|
Date :
2015-05-30 14:04:20 |
By :
ninenine |
View :
1607 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้มันติดที่บรรทัดที่เป็นสีแดงอะครับ ใครก็ได้ช่วยที่ครับ
Code (ASP)
<%
Dim Conn,strSQL,objExec,i
BDate= Request.Form("bday")
DDate=Date()
hdnMaxLine= Request.Form("hdnMaxLine")
SDCode = Request.Form("txtSDDealerCode")
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=L0820_WUTTISAA1;Database=OVCM;UID=ovcm;PWD=Ninekao9;"
for i=1 to i<=Request.Form("hdnMaxLine")
strSQL = ""
strSQL = strSQL &"INSERT INTO WLoyalty "
strSQL = strSQL &"(DocDate,SDCode,BFDealer,Product,QTY,UserCreate,CreateDate) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &" ('"&BDate&"','"&SDCode&"','"["Column1_".i]."','"["Column2_".i]."','"["Column3_".i]."','"&DDate&"')"
Set objExec = Conn.Execute(strSQL)
If Err.Number = 0 Then
%>
<meta http-equiv="refresh" content="3;URL=Truck_AddProfile.asp">
<table width="900" height="69" border="0" align="center">
<tr>
<td width="882" height="32" align="center"></td>
</tr>
<tr>
<td height="31" align="center"> </td>
</tr>
</table>
<p>
<%
'Response.write("Save Done.")
Else
Response.write("Error Save ["&strSQL&"] ("&Err.Description&")")
End If
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
</p>
|
|
|
|
|
Date :
2015-05-30 16:36:54 |
By :
ninenine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้มัน Error อะไรครับ
|
|
|
|
|
Date :
2015-05-31 07:58:12 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนนี้รันได้ครับ แต่ว่ามันไม่บันทึกข้อมูลลง DataBase ครับ จาก Code ใหม่อันนี้ครับ
Code : SaveInputSubDealerInvoice.asp
Code (ASP)
Dim Conn,strSQL,objExec,i
BDate= Request.Form("bday")
DDate=Date()
hdnMaxLine= Request.Form("hdnMaxLine")
SDCode = Request.Form("txtSDDealerCode")
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=L0820_WUTTISAA1;Database=OVCM;UID=ovcm;PWD=Ninekao9;"
for i=1 to i<=hdnMaxLine
strSQL = ""
strSQL = strSQL &"INSERT INTO WLoyalty "
strSQL = strSQL &"(DocDate,SDCode,BFDealer,Product,QTY,UserCreate,CreateDate) "
strSQL = strSQL &"VALUES "
strSQL = strSQL &" ('"&BDate&"','"&SDCode&"','"&Request.Form("Column1_".i)&"',"
strSQL = strSQL &" '"&Request.Form("Column2_".i)&"','"&Request.Form("Column3_".i)&"','"&DDate&"')"
Set objExec = Conn.Execute(strSQL)
next
%>
<meta http-equiv="refresh" content="3;URL=InputDataSubDealer.asp">
<table width="900" height="69" border="0" align="center">
<tr>
<td width="882" height="32" align="center"></td>
</tr>
<tr>
<td height="31" align="center"> </td>
</tr>
</table>
<p>
<%
Conn.Close()
Set objExec = Nothing
Set Conn = Nothing
%>
</p>
Code เพจส่งค่า : InputSubDealerInvoice.asp
Code (ASP)
<script language="javascript">
function SelectDealer(SelectValue1)
{
var objSelect = document.getElementById(SelectValue1);
var Item1 = new Option("", "");
objSelect.options[objSelect.length] = Item1;
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=L0820_WUTTISAA1;Database=OVCM;UID=ovcm;PWD=Ninekao9;"
strSQL = "SELECT * FROM AProfileDealer "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
While Not objRec.EOF
%>
{
var Item1 = new Option("<%=objRec.Fields("DealerName").Value%>", "<%=objRec.Fields("DealerName").Value%>");
objSelect.options[objSelect.length] = Item1;
}
<%
objRec.MoveNext
Wend
%>
}
function SelectProduct(SelectValue2)
{
var objSelect = document.getElementById(SelectValue2);
var Item2 = new Option("", "");
objSelect.options[objSelect.length] = Item2;
<%
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=L0820_WUTTISAA1;Database=OVCM;UID=ovcm;PWD=Ninekao9;"
strSQL = "SELECT * FROM LProduct "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
While Not objRec.EOF
%>
{
var Item2 = new Option("<%=objRec.Fields("ProductName").Value%>", "<%=objRec.Fields("ProductName").Value%>");
objSelect.options[objSelect.length] = Item2;
}
<%
objRec.MoveNext
Wend
%>
}
function CreateNewRow()
{
var intLine = parseInt(document.frmMain.hdnMaxLine.value);
intLine++;
var theTable = document.getElementById("tbExp");
var newRow = theTable.insertRow(theTable.rows.length)
newRow.id = newRow.uniqueID
var newCell
//*** Column 1 ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column1_"+intLine+"\" ID=\"Column1_"+intLine+"\"></SELECT></center>";
//*** Column 2 ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column2_"+intLine+"\" ID=\"Column2_"+intLine+"\"></SELECT></center>";
//*** Column 3 ***//
newCell = newRow.insertCell(2);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column3_"+intLine+"\" ID=\"Column3_"+intLine+"\" VALUE=\"\"></center>";
//*** Create Option ***//
SelectDealer("Column1_"+intLine)
SelectProduct("Column2_"+intLine)
document.frmMain.hdnMaxLine.value = intLine;
}
function RemoveRow()
{
intLine = parseInt(document.frmMain.hdnMaxLine.value);
if(parseInt(intLine) > 0)
{
theTable = document.getElementById("tbExp");
theTableBody = theTable.tBodies[0];
theTableBody.deleteRow(intLine);
intLine--;
document.frmMain.hdnMaxLine.value = intLine;
}
}
</script>
</head>
<body Onload="CreateNewRow();">
<%
'Check if user is logged in
if Session("name") = "" then
'If not, go to login page
Response.Redirect("login.asp")
else
'If, build page
%>
<!-- START PAGE SOURCE -->
<div class="main">
<div class="header">
<div class="header_resize">
<div class="logo">
<h1><a href="index.html">Loyalty Program <img src="images/pix1.jpg" width="58" height="58" /><small>put your slogan here</small></a></h1>
</div>
<div class="clr"></div>
<div class="menu_nav">
<ul>
<li><a href="Home.asp">Home</a></li>
<li><a href="Profile.asp">Profile</a></li>
<li class="active"><a href="InputData.asp">Input dAta</a></li>
<li><a href="blog.html">Report</a></li>
<li><a href="contact.html">Contact Us</a></li>
<li><a href="logout.asp">Logout</a></li>
</ul>
</div>
<div class="clr">
</div><table width="970" border="0" bgcolor="#FFFFFF">
<tr>
<td width="970">
<form action="SaveInputSubDealerInvoice.asp" name="frmMain" method="post">
<%
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "Driver={SQL Server};Server=L0820_WUTTISAA1;Database=OVCM;UID=ovcm;PWD=Ninekao9;"
strSQL = "SELECT * FROM AProfileSubDealer "
strSQL = strSQL & "WHERE SubDealerName LIKE '%"&Request.QueryString("CusID")&"%' "
Set objRec = Conn.Execute(strSQL)
If objRec.EOF Then
Response.write("Not found CustomerID="&Request.QueryString("CusID"))
Else
%>
<table width="900" height="214" border="0" align="center">
<tr>
<td height="32" colspan="4" align="center"><img src="images/KeyInInvoice.png" width="200" height="46" /> </th></td>
</tr>
<tr>
<td width="130" >Invoice Date : </td>
<td width="267" height="24" align="left"><input type="date" name="bday" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td >Sub Dealer Code :</td>
<td height="24" align="Left"><input name="txtSDDealerCode" type="text" disabled="disabled" value="<%=objRec.Fields("SubDealerName")%>" size="10" /><input name="txtSDDealerCode" type="hidden" value="<%=objRec.Fields("SubDealerName")%>" /></td>
<td width="131" height="24" align="Left">Sub Dealer Name : </td>
<td width="354" align="Left"><input name="txtDealerName" type="text" disabled="disabled" value="<%=objRec.Fields("SubDealerName")%>" size="40" /></td>
</tr>
<tr>
<td height="25" align="Left">Province</td>
<td height="25" align="Left"><input name="txtProvince" type="text" disabled="disabled" value="<%=objRec.Fields("Province")%>" size="20" /></td>
<td height="25" colspan="2" align="Left"> </td>
</tr>
<tr>
<td height="31" colspan="4" align="center">
<table width="800" border="1" id="tbExp">
<tr>
<td width="169"><div align="center">Dealer Name</div></td>
<td width="431"><div align="center">Product </div></td>
<td width="197"><div align="center">Amount (PCS.) </div></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="31" colspan="4" align="left"><input type="hidden" name="hdnMaxLine" value="0">
<input name="btnAdd" type="button" id="btnAdd" value="+" onClick="CreateNewRow();">
<input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();"></td>
</tr>
<tr>
<td height="31" colspan="4" align="center"><input type="image" value="submit" src="images/submit.gif" /></td>
</tr>
</table>
<p>
<%
End IF
objRec.Close()
Conn.Close()
Set objRec = Nothing
Set Conn = Nothing
%>
</p>
</form>
</tr>
</table></td>
</tr>
</table>
|
|
|
|
|
Date :
2015-05-31 12:04:24 |
By :
ninenine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมนำไปใส่แล้วครับ ไม่โชว์ค่าอะเลยอะครับ พี่ๆพอมีวิธีไหมครับ
|
|
|
|
|
Date :
2015-05-31 17:02:41 |
By :
ninenine |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (VB.NET)
strSQL = "INSERT INTO WLoyalty "
strSQL &= "(DocDate,SDCode,BFDealer,Product,QTY,UserCreate,CreateDate) "
strSQL &= "VALUES "
strSQL &= " ('"&BDate&"','"&SDCode&"','"&Request.Form("Column1_".i)&"',"
strSQL &= " '"&Request.Form("Column2_".i)&"','"&Request.Form("Column3_".i)&"','"&DDate&"')"
Dim Cmd as New Sqlcommand(strSql,Conn)
Cmd.ExecuteNonQuery
ลองดูครับว่า ข้อมูลลงdatabase หรือเปล่า
|
|
|
|
|
Date :
2015-08-06 11:58:18 |
By :
deksalum |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|