Is this good way?
- private void Button2_Click(object sender, EventArgs e) //Save pdf in database
- {
- 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();
- }
- }
- }
Shweta LodhaPosted Aug 6, 2018, 3:13 AM
Raghavendar SwaminathanPosted Aug 6, 2018, 2:32 AM
Goran BibicPosted Aug 6, 2018, 2:28 AM
Raghavendar Swaminathan
Raghavendar SwaminathanPosted Aug 6, 2018, 2:21 AM
Goran BibicPosted Aug 6, 2018, 2:10 AM
Raghavendar Swaminathan
But need some helpGoran BibicPosted Aug 6, 2018, 2:08 AM
Raghavendar SwaminathanPosted Aug 6, 2018, 2:07 AM
Goran BibicPosted Aug 6, 2018, 2:02 AM
Raghavendar SwaminathanPosted Aug 6, 2018, 1:59 AM
Shweta LodhaPosted Aug 6, 2018, 1:57 AM