void Form1_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) { Guid id = Guid.NewGuid(); FileInfo fileInfo = new FileInfo(file); string navn = fileInfo.Name; frmAddDoc m_frmAddDoc = new frmAddDoc(); m_frmAddDoc.Dokument = navn; m_frmAddDoc.ShowDialog(); Tbldoc rec_doc = new Tbldoc { Id = id, Navn = navn, Selskab = m_frmAddDoc.Selskab, åR = m_frmAddDoc.År, Produkt = m_frmAddDoc.Produkt }; db.Tbldoc.InsertOnSubmit(rec_doc); FileStream fs = fileInfo.OpenRead(); long ln = fileInfo.Length; byte[] file_byte = new byte[ln]; fs.Read(file_byte, 0, (int)ln); System.Data.Linq.Binary file_binary = new System.Data.Linq.Binary(file_byte); TblData rec_Data = new TblData { Id = id, Data = file_binary }; db.TblData.InsertOnSubmit(rec_Data); db.SubmitChanges(); var qry = from doc in db.Tbldoc select doc; tbldocBindingSource.DataSource = qry; } }
partial void DeleteTblData(TblData instance);
partial void UpdateTblData(TblData instance);
partial void InsertTblData(TblData instance);