Insert data with image in Sql server database in C#

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to our programming channel today in c sharp we will see how to insert data with image in sql server database in chart win forms we will see this kind of small application for insulting data db insert with image is database and table is grocery items table have columns id in category where care 50 item where 50 quantity in unit vehicle 20 price decimal 10 2 amount decimal day 2. picture image for picture data type is image and we don't want to allow nulls for id we have given primary key and identity specification is identity yes new project c sharp windows forms application project name db insert with image in c sharp we first make connection with sql server server explorer data connections right click add connection here selection must be microsoft sql server okay then server name for server name right click connect and this is the server name copy this and paste here database is db insert with image db insert with image test connection this connection succeeded okay okay now project is connected with sql server before starting designing and coding we first give connection stream in f config file in app config file connection streams add name is equal to pawn db connection string is equal to this is the connection right click properties connection stream double click on this now this connection stream is selected copy with ctrl c paste with ctrl v provider name is equal to okay system dot data dot sql client now the connection string part is ready first we take one group box desktop form we can give any text grocery with image and here for group box grocery we can give back color for group box we need 5 labels we can change the font of label we need five text boxes select all the text boxes and properties and here for size 12. now the height of the text boxes is also increasing category item you need price amount txt category takes the item txt unit txt price txt amount we have taken two buttons btn new and text is new here also we can give the size btn save text save and font we take one picture box we can change background color or form also light sky blue for selecting image we need one more button btn image select select image suppose we click on group box or label button then this kind of event automatically generate if we delete this and save this then then there will be this kind of error so first first clear this event save and now we can delete this and save this and there is no any error using system dot configuration and using system dot data dot sql client for configuration we need to add reference so select references right click add reference select system dot configuration [Music] okay so string constraint is equal to configuration manager dot connection strings in square bracket in double quotes name of the connection string is 1db copy paste dot connection stream double click on this new button we get click event okay we can clear the text boxes and picture box when we click new button or also we can clear text boxes and picture box after saving the record we have not taken quantity here so quantity xp and for this picture box border style is none border style pixel single now we can see picture box double click on select image button open file dialog o f d l g o f d l g dot title open image of dlg dot filter we want to open only image files so we have given filter here dot show dialog is equal to dialog result okay name of the picture box is picture box one picture box one dot image is equal to image dot from file of dmg dot file name let's see what happens now we can select the image file in picture box but the image is not getting properly so here size mode stretch image now image is getting properly now we want to save all the information in text boxes and image in picture box so double click on save button image pimg is equal to picture box 1 dot image the image converter converter is equal to new image converter you now we want to store the image in binary format in database we have taken image convert variable first we open the connection you so command dot parameters add with value category txt category dot test at the rate item takes the item a direct quantity takes the quantity at the rate you need txt you need txt price i dare it i'm on takes the amount added picture image convert cmd dot execute non query conduct close added successfully here we have not given coin here must be called and here you know values values and here grocery items if we run the project before entering the records we set the tab index property for buttons and text boxes to avoid the use of mouse and easily enter record with keyboard for new button appendage property is 0 for category text box it is 1 for item 2 for quantity 3 for unit 4 for price 5 for amount 6 for select image 7 and for save button 8 and for new button 0. this is a record of apple this is record of banana with image now the category is braid this is record of white blade with image this is record of downward with image now the category is dairy this is the record of butter with image this is the record of cheese with image this is the record of milk with image if we see in table then we can see these are the records which we have entered and these are the images instead of select if we edit then here we can see images are stored in binary format in this way we can insert data in sql server with images in further video we will see how to retrieve this data with images that's all for today in our channel there are regular uploads of programming related videos so for latest updates please subscribe the channel and like and share videos thanks for watching
Info
Channel: EasySQLWorld
Views: 11,144
Rating: undefined out of 5
Keywords: insert data in database in c#, insert image in database in c#, c# tutorial, how to save image in database in .net, how to save image in database in, how to save image in database in c#, how to save image in database using c#, csharp tutorial, csharp tutorial for beginners, c sharp tutorial advanced
Id: ONmXIh-LnZs
Channel Id: undefined
Length: 37min 43sec (2263 seconds)
Published: Tue Jan 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.