I'm trying to Get a Value From the variable I Diclear in a private Method and I want to use that value in another private method
First I want to add a picture in the Picture box I create this Button after using FileDialog for browsing pictures I saved the file path in a string named PicPath.
private void Add_Pic_bt_Click(object sender, EventArgs e)
{
// open file dialog
OpenFileDialog open = new OpenFileDialog();
// image filters
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp; *.png)|*.jpg; *.jpeg; *.gif; *.bmp; *.png";
if (open.ShowDialog() == DialogResult.OK)
{
// display image in picture box
Std_Pic.Image = new Bitmap(open.FileName);
// image file path
string Picpath = open.FileName;
}
}
what I want is to call that variable another button so I can add the file path to the database.
private void Save_Info_bt_Click(object sender, EventArgs e)
{
string DateOfBirth = Std_Year_tx.Text + "/" + Std_Month_tx.Text + "/" + Std_Day_tx.Text;
OleDbDataAdapter InfoSave = new OleDbDataAdapter(" INSERT INTO [StudentInfo] (Name, Student_ID, Departmint, Stage, Date_Of_Birth, Email_Address, Phone_Number, Profile_Picture ) values('" + Std_Name_tx.Text + "', '" + Std_ID_tx.Text + "','" + Std_Dep_cb.Text + "', '" + Std_Stage_cb.Text + "', '" + DateOfBirth + "', '" + Std_Email_tx.Text + "', '" + Std_Num_tx.Text + "', '"+ Picpath + "')", Mycon) ;
DataSet DataSave = new DataSet();
InfoSave.Fill(DataSave);
}
NOTE: I'm new to C# im trying to learn by making this kind of stuff So if u can explain in a simple way And thank you for your time.
Software: Visual Studio 2019. Database: MS Access 2019.