|  | 
	                
  
    |  |  
    | 
        
        สอบถามการแสดงรูปภาพจาก Sql Server ใน VB  จากเครื่อง Server     |  
    |  |  
 
	
		|  |  |  |  |  
		|  |  | 
          
            | พอดีเขียนโปรแกรมเป็น win app โดยเชื่อต่อกับ SQL SERVER ติดปัญเรื่องการเก็บและการแสดงรูปภาพคะ โดยค่าที่เก็บจะเก็บเป็น file name คะ ซึ่งจะอิงกับคอมพิวเตอร์เครื่องนั้นๆ
 เลยเกิดปัญหาว่า ถ้านำโปรแกรมไปติดตั้งกับเครื่องอื่นจะไม่สามารถแสดงรูปภาพได้เนื่องจาก ไม่มี file รูปภาพตามชื่อที่เก็บไว้ใน DB
 จึงอยากจะสอบถามว่าพอจะมีวิธีไหนบ้างคะที่สามารถทำได้
 
 
 [font=Verdana]ตัวอย่างโค้ดบันทึก[/font]
 Code (VB.NET)
 
  strsql = "INSERT INTO Purchase_Machine(PO_no ,Mac_no ,Date ,Sup_id)"
                strsql &= "VALUES('" & txtPO.Text & "' ,'" & txtMachineNo.Text & "' ,'" & txtDate.Text & "' ,'" & txtSupID.Text & "')"
                With cmd
                    .Connection = con
                    .CommandText = strsql
                    .CommandType = CommandType.Text
                    .ExecuteNonQuery()
                End With
 [font=Verdana]ตัวอย่างโค้ดแสดงรูปภาพ[/font]
 Code (VB.NET)
 
 Private Sub dgvMachine_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvMachine.CellClick
        If e.RowIndex = -1 Then Exit Sub
        With dgvMachine
       
            PictureBox1.Image = Image.FromFile(path)
         
        End With
    End Sub
 ข้อมูลที่จัดเก็บลง SQL Server
 
 
  
 
 ขอบคุณคะ
 
 
 
 Tag : .NET, Ms SQL Server 2012, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2017-06-30 14:06:06 | By :
                          Preeyapan | View :
                          1114 | Reply :
                          3 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |  
		|  |  |  |  |  
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ขอโทษคะ โค้ดบันทึก เป็นโค้ดนี้คะ 
 Code (VB.NET)
 
  strsql = "INSERT INTO Machine(Mac_no ,Mac_name ,Line_id ,Sup_id ,FileName)"
            strsql &= "VALUES('" & txtMachineNo.Text & "' ,'" & txtMachineName.Text & "' ,'" & cbxLineID.Text & "' ,'" & txtSupID.Text & "' ,'" & txtpath.Text & "')"
            With cmd
                .Connection = con
                .CommandText = strsql
                .CommandType = CommandType.Text
                .ExecuteNonQuery()
                MessageBox.Show("Create Machine Master List in database complete.", "Create Machine Master List", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End With
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2017-06-30 14:09:29 | By :
                            Preeyapan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              |  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2017-07-01 10:05:01 | By :
                            mr.win |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |