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,028

HOME > ASP > ASP Forum > เกิดจากอะไรเกี่ยวกับฐานข้อมูลด้วยหรือเปล่า This key is already associated with an element of this collection ตอนอัพเดทเพื่อส่งค่าไป key มี 2 ตัว



 

เกิดจากอะไรเกี่ยวกับฐานข้อมูลด้วยหรือเปล่า This key is already associated with an element of this collection ตอนอัพเดทเพื่อส่งค่าไป key มี 2 ตัว

 



Topic : 039109

Guest




This key is already associated with an element of this collection

ตอนอัพเดทเพื่อส่งค่าไป key มี 2 ตัว
a คีย์หลัก
ิิ b คีย์ร่วม
สงสัยจังเลยคะ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2010-02-17 10:33:02 By : jyp View : 1728 Reply : 5
 

 

No. 1



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

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

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


ไม่เคยเจอแบบนี้นะคับ แต่เท่าที่ดูตาม Error ก็น่าแสดงว่า มีการส่งไปผิด อาจจะ ซ้ำซ้อน หรือไง ไม่ทราบ ไม่เคยเจอ

ลองส่งไปทีละตัวดูนะคับ ส่งแค่ a ไปแล้วรับได้ไหม ไม่ error ต่อไปก็ส่ง a,b ไป ว่ารับได้ไหม ถ้ารับได้ก็ Debug ลำดับ

ต่อไปคับ






Date : 2010-02-17 12:51:49 By : inanosms
 


 

No. 2

Guest


มีค่ามานะคะแต่ทำไมมันฟ้อง file upload
This key is already associated with an element of this collection
Date : 2010-02-17 13:38:50 By : jpy
 

 

No. 3



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



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


file upload

Code (ASP)
<%
Sub BuildUploadRequest(RequestBin)
	PosBeg = 1
	PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
	boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
	boundaryPos = InstrB(1,RequestBin,boundary)
	Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
		Dim UploadControl
		Set UploadControl = CreateObject("Scripting.Dictionary")
		Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
		Pos = InstrB(Pos,RequestBin,getByteString("name="))
		PosBeg = Pos+6
		PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
		Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
		PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
		PosBound = InstrB(PosEnd,RequestBin,boundary)
		If  PosFile<>0 AND (PosFile<PosBound) Then
			PosBeg = PosFile + 10
			PosEnd =  InstrB(PosBeg,RequestBin,getByteString(chr(34)))
			FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
			UploadControl.Add "FileName", FileName
			Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
			PosBeg = Pos+14
			PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
			ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
			UploadControl.Add "ContentType",ContentType
			PosBeg = PosEnd+4
			PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
			Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
			Else
			Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
			PosBeg = Pos+4
			PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
			Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
		End If
	UploadControl.Add "Value" , Value	
	UploadRequest.Add name, UploadControl	'บรรทัดที่ error
		BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
	Loop

End Sub

Function getByteString(StringStr)
 For i = 1 to Len(StringStr)
 	char = Mid(StringStr,i,1)
	getByteString = getByteString & chrB(AscB(char))
 Next
End Function

Function getString(StringBin)
 getString =""
 For intCount = 1 to LenB(StringBin)
	getString = getString & chr(AscB(MidB(StringBin,intCount,1))) 
 Next
End Function

%>



file aaa ส่งค่าไป


ค่าที่ส่งไป

Code (VB.NET)
<!--#include file=upload.asp-->
<%

	len1=Len(request("url"))-InstrRev(request("url"),"/") 
	pathinfo=Server.mappath(Request.ServerVariables("PATH_INFO"))
	pathEnd = Len(pathinfo)-len1
	
	filepath=left(pathinfo,pathEnd) & "image_personal\"
	
	Response.Expires=0
	Response.Buffer = TRUE
	Response.Clear
	
	byteCount = Request.TotalBytes
	
	RequestBin = Request.BinaryRead(byteCount)
	Dim UploadRequest
	Set UploadRequest = CreateObject("Scripting.Dictionary")
	BuildUploadRequest  RequestBin
	
	Id = UploadRequest.Item("Id_").Item("Value")
	Title_id = UploadRequest.Item("Title_id").Item("Value")
%>


Error

Error Type:
Microsoft VBScript runtime (0x800A01C9)
This key is already associated with an element of this collection
/test/upload.asp, line 37
ตรงที่บันทัดนี้ error
UploadRequest.Add name, UploadControl บรรทัดสีแดง
Date : 2010-02-18 14:50:17 By : jpy
 


 

No. 4



โพสกระทู้ ( 3,144 )
บทความ ( 1 )

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

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


อันนี้โปรเจ็คเก่า เอาไปดู ไปก็อบ ไปใช้

Conn.asp
<%
connstr = "Driver={SQL Server};Server=10.0.102.9;Database=MyDatabase;UID=MyUser;Pwd=MyPassword"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConnStr
%>


CloseConn.asp
<%
Conn.Close
Set Conn = Nothing
%>


AddFile.asp
<!--#include file="include/conn.asp" -->

<html>
<head>
	<meta name="vs_defaultClientScript" content="JavaScript">
	<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	<meta http-equiv="content-Type" content="text/html; charset=windows-874">
	<meta name="Author" content="tungman">
	<meta name="Keywords" content="">
	<meta name="Description" content="">
	<title>::: Upload File :::</title>
</head>
<SCRIPT LANGUAGE="JavaScript">

// Begin
// คำสั่ง java script สำหรับการตรวจสอบการป้อนข้อมูล
function validate(){

     if (document.upload.detail.value=="") {
          alert("กรุณาป้อน คำอธิบายของ file..!");
          document.upload.detail.focus();
          return false;
     }
     if (document.upload.file.value=="") {
          alert("กรุณาเลือก File ที่ต้องการ upload..!");
          document.upload.file.focus();
          return false;
     }
     if (confirm("คุณต้องการส่ง file ที่คุณเลือกหรือไม่?")) {
          return true;
     } else {
          return false;
     } 
}
function MM_goToURL() { //v3.0
	var i, 

	args = MM_goToURL.arguments; 
	document.MM_returnValue = false;
	for (i = 0; i<(args.length-1); i += 2) 
		eval(args[i]+".location='" + args[i+1] + "'");
}
// End -->
</script> 
<body>

<!-- Insert HTML here -->
<%
		Set RSproject = Conn.Execute("Select [GOVSERV_PROJECT].[PROJECT_NAME], [GOVSERV_PROJECT].[PROJECT_ID], [GOVSERV_PROJECT].[PROJECT_FILE], [GOVSERV_DIVISION].[DIVISION_SNAME] From [GOVSERV_PROJECT] Inner Join [GOVSERV_DIVISION] On [GOVSERV_DIVISION].[DIVISION_ID] = [GOVSERV_PROJECT].[DIVISION_ID] Where [GOVSERV_PROJECT].[PROJECT_ID]="& Request("id"))
%>

<form name="upload" action="uploadfile.asp" method="post" enctype="multipart/form-data" onsubmit="return validate();">
<input type="hidden" name="id" value="<%=RSproject("PROJECT_ID")%>">
<table width="100%" border="0">
      <tr>
          <td width="100%" colspan="2"><b><%=RSproject("PROJECT_NAME")%> - <%=RSproject("DIVISION_SNAME")%></b></td>
     </tr>
     <tr>
          <td width="30%" nowrap>คำอธิบาย file:</td>
          <td width="70%"><input type="text" name="detail"></td>
     </tr>
     <tr>
          <td nowrap>File ที่ต้องการ Upload:</td>
          <td><input type="file" name="file"> <font color="#FF0000">* ขนาดไฟล์ต้องไม่เกิน 10 Mbytes</font></td>
     </tr>
     <tr>
          <td>&nbsp;</td>
          <td><input type="submit" name="Submit" value="Submit">
          <input type="reset" name="Submit2" value="Reset">
		<input type="button" value=" Back " onClick="MM_goToURL('parent','showfile.asp?id=<%=RSproject("PROJECT_ID")%>');return document.MM_returnValue;">
          </td>
     </tr>
</table>
</form>
</body>
</html>

<!--#include file="include/closeconn.asp" -->


UploadFile.asp
<!--#include file="include/conn.asp" -->

<%
' Author Philippe Collignon
' Email [email protected]
' Credit ให้เขาด้วยนะครับกรุณาอย่าเอาออก 

Response.Expires = 0
Response.Buffer = True
Response.Clear
byteCount = Request.TotalBytes
RequestBin = Request.BinaryRead(byteCount) 
Dim UploadRequest
Set UploadRequest = CreateObject("Scripting.Dictionary")

BuildUploadRequest RequestBin
contentType = UploadRequest.Item("file").Item("ContentType")
filepathname = UploadRequest.Item("file").Item("FileName")
filename = Right(filepathname,Len(filepathname)-InstrRev(filepathname,"\"))

values = UploadRequest.Item("file").Item("Value")
detail = UploadRequest.Item("detail").Item("Value") 
id = UploadRequest.Item("id").Item("Value") 

Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject")
FilePath = Server.MapPath("excel") & "\" & filename 

Set MyFile = ScriptObject.CreateTextFile(FilePath)

For i = 1 to LenB(values)
	MyFile.Write chr(AscB(MidB(values,i,1)))
Next

MyFile.Close
%>

<font face='ms Sans serif' size=-1>
<!--Upload ไปยัง path :<%=filePath%><br>-->
ชื่อ file : </b><%=filename%><br>
คำอธิบาย : <%=detail%><br>
<a href="showfile.asp?id=<%=id%>">คลิกที่นี่เพื่อย้อนกลับ</a>

<!--#include file="inc_upload.asp"-->
<%
	Conn.Execute("Update [GOVSERV_PROJECT] Set [PROJECT_FILE]=1 Where [PROJECT_ID]="& id)
	Conn.Execute("Insert Into [PROJECT_FILE] ([PROJECT_ID], [FILE_NAME], [FILE_DETAIL]) Values ("& id &", '"& filename &"', '"& detail &"')")
%>
<!--#include file="include/closeconn.asp" -->


inc_upload.asp
<%
' Author Philippe Collignon 
' Email [email protected]
' Credit ให้เขาด้วยนะครับกรุณาอย่าเอาออก 

Sub BuildUploadRequest(RequestBin)
     PosBeg = 1
     PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
     boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
     boundaryPos = InstrB(1,RequestBin,boundary)

     Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
          Dim UploadControl
          Set UploadControl = CreateObject("Scripting.Dictionary")
          Pos = InstrB(BoundaryPos,RequestBin,getByteString("Content-Disposition"))
          Pos = InstrB(Pos,RequestBin,getByteString("name="))
          PosBeg = Pos+6
          PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
          Name = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
          PosFile = InstrB(BoundaryPos,RequestBin,getByteString("filename="))
          PosBound = InstrB(PosEnd,RequestBin,boundary)

          If PosFile<>0 AND (PosFile<PosBound) Then
               PosBeg = PosFile + 10
               PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(34)))
               FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
               UploadControl.Add "FileName", FileName
               Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
               PosBeg = Pos+14
               PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
               ContentType = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
               UploadControl.Add "ContentType",ContentType
               PosBeg = PosEnd+4
               PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
               Value = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
          Else
               Pos = InstrB(Pos,RequestBin,getByteString(chr(13)))
               PosBeg = Pos+4
               PosEnd = InstrB(PosBeg,RequestBin,boundary)-2
               Value = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
          End If

          UploadControl.Add "Value" , Value 
          UploadRequest.Add name, UploadControl 
          BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
     Loop
End Sub 
Function getString(StringBin)
     getString =""
     For intCount = 1 to LenB(StringBin)
           getString = getString & chr(AscB(MidB(StringBin,intCount,1))) 
     Next
End Function

'String to byte string conversion
Function getByteString(StringStr)
     For i = 1 to Len(StringStr)
          char = Mid(StringStr,i,1)
          getByteString = getByteString & chrB(AscB(char))
     Next
End Function

%> 

Date : 2010-02-18 17:00:06 By : tungman
 


 

No. 5

Guest


มีไฟล์ฐานข้อมูลมั้ยครับ ขอด้วย
Date : 2010-05-12 15:59:47 By : อาท
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : เกิดจากอะไรเกี่ยวกับฐานข้อมูลด้วยหรือเปล่า This key is already associated with an element of this collection ตอนอัพเดทเพื่อส่งค่าไป key มี 2 ตัว
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 00
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 อัตราราคา คลิกที่นี่