  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                คือ จาก link http:// https://www.thaicreate.com/free-web-script/asp.net-upload-file-blob-binary-data.html 
 
ผมทำการ insert ข้อมูลรูปภาพ แต่ไม่ได้ insert โดยใช้ Code แบบตัวอย่างอะครับ ผมใช้ LINQ ในการ Insert มี code ดังนี้ 
 
Code (VB.NET) 
        Dim ext As String = System.IO.Path.GetExtension(FileUpload1.FileName.ToString)
        path = Server.MapPath(".\\Profile\\")
        If FileUpload1.HasFile = False Then
            Info.UpdatePanelInfo("กรุณาเลือกไฟล์", Me.Page)
        Else
            If (ext = ".jpg" Or ext = ".png" Or ext = ".bmp") Then
                '*** Read Binary Data ***'
                Dim imbByte(FileUpload1.PostedFile.InputStream.Length) As Byte
                FileUpload1.PostedFile.InputStream.Read(imbByte, 0, imbByte.Length)
                '***insert database ***'
                Dim db As New OfficerdbDataContext
                Dim img = From p In db.Officers _
                          Where p.OfficerCode.ToString = Session("OfficerCodeSearch").ToString
                img.Single.Pic = imbByte
                db.SubmitChanges()
            Else
                Info.UpdatePanelInfo("อัพโหลดเฉพาะรูปภาพ .jpeg หรือ .png หรือ gif เท่านั้น", Me.Page)
            End If
        End If
 
 
 
ทีนี้ จาก link ดังกล่าว จะมีบรรทัดนี้เพื่อให้ Add parameter น่ะครับ 
 
objCmd.Parameters.Add("@sName", SqlDbType.VarChar).Value = Me.txtName.Text 
51. 
objCmd.Parameters.Add("@sFilesName", SqlDbType.Binary).Value = imbByte 
52. 
objCmd.Parameters.Add("@sFilesType", SqlDbType.VarChar).Value = strMIME 
 
 
ซึ่งถ้าผมใช้ LINQ ผมไม่มีบรรทัดดังกล่าว  จะทำการดึงรูปออกมาอย่างไรครับ 
 
รบกวนขอคำแนะนำด้วยครับ
 
 
  Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), LINQ, VB.NET, VS 2010 (.NET 4.x)               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2012-09-13 20:14:32 | 
                      By :
                          phokhai | 
                      View :
                          1272 | 
                      Reply :
                          6 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |