C
C#9mo ago
𝕏

❔ need help , data will not save when I select pdf to upload

save button
C#
private void btnAddnew_Click(object sender, EventArgs e)
{
try
{
//add new report
HCDBAppData.tblreports.AddtblreportsRow(HCDBAppData.tblreports.NewtblreportsRow());
tblreportsBindingSource.MoveLast();
comboBox1.Focus();
C#
private void btnAddnew_Click(object sender, EventArgs e)
{
try
{
//add new report
HCDBAppData.tblreports.AddtblreportsRow(HCDBAppData.tblreports.NewtblreportsRow());
tblreportsBindingSource.MoveLast();
comboBox1.Focus();
browse button
C#

try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "PDF Files|*.pdf";
openFileDialog.Title = "Select a PDF File";

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string pdfFilePath = openFileDialog.FileName;
string fileName = Path.GetFileName(pdfFilePath);


// Display the selected file path in a TextBox or label
txtFileName.Text = fileName;
C#

try
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "PDF Files|*.pdf";
openFileDialog.Title = "Select a PDF File";

if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string pdfFilePath = openFileDialog.FileName;
string fileName = Path.GetFileName(pdfFilePath);


// Display the selected file path in a TextBox or label
txtFileName.Text = fileName;
btnSave
C#
private void btnSave_Click(object sender, EventArgs e)
{

try
{
//save new report

tblreportsBindingSource.EndEdit();

int rowsAffected = tblreportsTableAdapter.Update(HCDBAppData.tblreports);

if (rowsAffected > 0)
{
HCDBAppData.AcceptChanges();
dataGridView9.Refresh();
MessageBox.Show("Report successfully uploaded", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

C#
private void btnSave_Click(object sender, EventArgs e)
{

try
{
//save new report

tblreportsBindingSource.EndEdit();

int rowsAffected = tblreportsTableAdapter.Update(HCDBAppData.tblreports);

if (rowsAffected > 0)
{
HCDBAppData.AcceptChanges();
dataGridView9.Refresh();
MessageBox.Show("Report successfully uploaded", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);

tblReports CREATE TABLE [dbo].[tblreports] ( [Id] INT IDENTITY (1, 1) NOT NULL, [p_name] VARCHAR (50) NULL, [test] VARCHAR (50) NULL, [chargers] VARCHAR (50) NULL, [report] VARBINARY (MAX) NULL, PRIMARY KEY CLUSTERED ([Id] ASC) );
2 Replies
JakenVeina
JakenVeina9mo ago
what is tblreportsBindingSource? and tblreportsTableAdapter? and HCDBAppData.tblreports?
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts