  | 
		 		   | 
	  	    
          
            
			
	
			
			 
                Code (C#) 
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            open.InitialDirectory = "C:\\";
            open.Filter = "Image File (*.jpg)|*.jpg|All Files(*.*)|*.*";
            open.FilterIndex = 1;
            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (open.CheckPathExists)
                {
                    OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\PEERAKIT\source\repos\WindowsFormsApp1\WindowsFormsApp1\imagepath.accdb; Persist Security Info = False; ");
                    string CorrectFilename = System.IO.Path.GetFileName(open.FileName);
                    OleDbCommand cmd = new OleDbCommand("INSERT INTO xxx (ID,path) values ((Select isnull(Max(Id),0) + 1 from xxx),'\\image\\" + CorrectFilename + "')", con);
                    cmd.ExecuteNonQuery();
                    con.Close();
                    string path = Application.StartupPath.Substring(0, (Application.StartupPath.Length - 10));
                    System.IO.File.Move(open.FileName, path + "\\image\\" + CorrectFilename);
                    MessageBox.Show("Successfully Uploaded");
                }
            }
        }
 
 
  
Error น่าจะเปิดจากการเขียน insert ไม่รู้ว่าผิดตรงส่วนไหน 
  
Type ของ ID = number path = short text  
 
ขอบคุณมากๆครับ
 
 
  Tag : .NET, Ms Access, Win (Windows App), C#, VS 2017 (.NET 4.x), Windows               
                        | 
           
          
            | 
			
                             | 
           
          
            
              
                   | 
                   | 
                   | 
               
              
                   | 
                
                    
                      | Date :
                          2018-04-29 18:14:01 | 
                      By :
                          snowman0020 | 
                      View :
                          924 | 
                      Reply :
                          2 | 
                     
                  | 
                   | 
               
              
                   | 
                   | 
                   | 
               
              | 
           
          
            | 
			 | 
           
         
	    
		             | 
		
			  |