Some help please
Insert into sql
- byte[] filedata = null;
- MemoryStream ms = new MemoryStream();
- filedata = ms.GetBuffer();
- axAcroPDF1.src = LocalEncoding.GetString(ms.ToArray());
- using (SqlConnection openCon = new SqlConnection(cs))
- {
- string saveStaff = "declare @maxNo integer = 0 select @maxNo = isnull(max(number), 0) from [dbo].[documents]; Set @maxNo=@maxNo+1; INSERT into dbo.documents (number, file_location, pdf_file) VALUES (@maxNo,@file_location,@pdf_file)";
- using (SqlCommand querySaveStaff = new SqlCommand(saveStaff))
- {
- querySaveStaff.Connection = openCon;
- querySaveStaff.Parameters.Add("@file_location", SqlDbType.VarChar, 255).Value = file_locationTextBox.Text;
- querySaveStaff.Parameters.AddWithValue("@pdf_file",SqlDbType.VarBinary).Value=filedata;
- openCon.Open();
- querySaveStaff.ExecuteNonQuery();
- openCon.Close();
- }
- }
- }
In Selection change datagrid put this
- try
- {
- if (documentsDataGridView.SelectedRows[0].Cells["pdf_file"].Value != null)
- {
- byte[] ap = (byte[])documentsDataGridView.SelectedRows[0].Cells["pdf_file"].Value;
- MemoryStream ms = new MemoryStream(ap);
- axAcroPDF1.src = LocalEncoding.GetString(ms.ToArray());
- }
- else {
- axAcroPDF1.src = null;
- }
- }
- catch
- {
- axAcroPDF1.src = null;
- }
I think at line 3 to line 9

Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 30, 2018, 9:47 PM EDT
Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 30, 2018, 9:53 PM EDT
Jenith ThakkarRank #789 · 2.9K reputationPosted Jul 30, 2018, 11:44 PM EDT
Goran BibicRank #993 · 2K reputationPosted Jul 30, 2018, 9:49 PM EDT
Goran BibicRank #993 · 2K reputationPosted Jul 30, 2018, 10:53 PM EDT
Goran BibicRank #993 · 2K reputationPosted Jul 30, 2018, 11:34 PM EDT
Goran BibicRank #993 · 2K reputationPosted Jul 30, 2018, 11:54 PM EDT