Link to home
Create AccountLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net VB.net Insert picture into SQL database

Hi

I have a SQL table with a varbinary column. I need a user on my webform to be able to click a button that inserts an image
into the database. If I know the path of  the database, how would the SQL statement look?

Thanks
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Pls try .. This code will read the data from the table and save the jpg file @ E drive with name Pawan.jpg.

4 part name [PAWAN452801].[ABCInvestment].data.CreditReport ----- ServerName.DatabaseaName.Schema.TableName

	

	DECLARE  @Command NVARCHAR(4000)=''
	
	SET @Command = 'bcp " ' + 'SELECT CreditReport FROM [PAWAN452801].[ABCInvestment].data.CreditReport ' 
                   + ' queryout "E:\Pawan' + '.jpg' + '"' + ' -T -N'
 
	PRINT @Command
 
	EXEC xp_cmdshell  @Command


	

Open in new window

Avatar of Murray Brown

ASKER

Hi

Thank you. I need to do this in VB.net
ASKER CERTIFIED SOLUTION
Avatar of Pawan Kumar
Pawan Kumar
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Hi. Thank you for the feedback but I need this to all happen in my VB.net application because it has to work with any database from my app
ohhh okies... cool. go ahead....
Thanks for the help. I can work out the rest