Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > ASP > ASP Forum > ช่วยดูให้หน่อยครับว่าผิดต้องไหนครับ ลองแปลงมาจาก PHP อะครับ



 

ช่วยดูให้หน่อยครับว่าผิดต้องไหนครับ ลองแปลงมาจาก PHP อะครับ

 



Topic : 116844



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์




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">&nbsp;</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 &copy; 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







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2015-05-30 14:04:20 By : ninenine View : 1526 Reply : 6
 

 

No. 1



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์


ตอนนี้มันติดที่บรรทัดที่เป็นสีแดงอะครับ ใครก็ได้ช่วยที่ครับ

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">&nbsp;</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
 


 

No. 2



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ตอนนี้มัน Error อะไรครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-05-31 07:58:12 By : mr.win
 

 

No. 3



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์


ตอนนี้รันได้ครับ แต่ว่ามันไม่บันทึกข้อมูลลง 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">&nbsp;</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">&nbsp;</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">&nbsp;</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
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code
Set objExec = Conn.Execute(strSQL) Response.write Err.Description

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-05-31 16:25:37 By : mr.win
 


 

No. 5



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์


ผมนำไปใส่แล้วครับ ไม่โชว์ค่าอะเลยอะครับ พี่ๆพอมีวิธีไหมครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2015-05-31 17:02:41 By : ninenine
 


 

No. 6



โพสกระทู้ ( 2 )
บทความ ( 0 )



สถานะออฟไลน์


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
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยดูให้หน่อยครับว่าผิดต้องไหนครับ ลองแปลงมาจาก PHP อะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่