0

I'm want to save an image to a sql server DB by using it's path, that i don't want to save the image it self i just want when i upload an image to my form and when i click in a button this button upload the image to the application folder then save the path of this picture to the databasen, How can I do that ?

2 - how can i add this picture to a dataGridView ?

NOTE : I'm using C# as a programming language.

1 Answer 1

1

Getting the image file path can be done using OpenFileDialog.
This answer can help you getting file path Extracting Path from OpenFileDialog path/filename

1) You can copy them using File.Copy(path, path2) function to your app directory :

string path = Directory.GetCurrentDirectory();

2) You need to use Bitmap to get your image loaded from its file path :

Bitmap myBmp = Bitmap.FromFile("path here");

And then you can add it to a DataGridView assuming that contains DataGridViewImageColumn

yourDataGridView.Rows.Add(<column1 value>, <column2 value>, myBmp, <column3 value>, <column4 value>);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.