Insert Into [dbo].[Letterland] ([letter],[letterImage])
Select 'a', BulkColumn,
From Openrowset (bulk 'H:\Data\D\ll-image\annie.png', Single_blob) as img
Insert Into [dbo].[Letterland] ([letterDescAudio])
Select 'a', BulkColumn, BulkColumn
From Openrowset (bulk 'H:\Data\D\11-image\aa.wav' Single_blob) as img
Insert Into [dbo].[Letterland] ([letterSound])
Select 'a', BulkColumn, BulkColumn
From Openrowset (bulk 'H:\Data\D\ll-image\a.wav', Single_blob) as img
This is what I tried but I know that it is incorrect. I am trying to insert the data as a single row.
[dbo].[Letterland] ([Letter], [letterImage], [letterDescAudio], [letterSound])
What you can do is save the file path to the database. Say your audio file is in path '~/audio/1.mp3'. So you can insert it in the database table as:
string audio = <your path to audio>;
INSERT INTO [TABLE NAME] VALUES(audio);
Well, you need to load your three blobs first, into variables, and then do a single INSERT
to insert them all into your table - something like this:
-- declare a VARBINARY(MAX) variable to hold the "image"
DECLARE @Image VARBINARY(MAX)
-- load the "image"
SELECT @Image = BulkColumn,
FROM Openrowset (bulk 'H:\Data\D\ll-image\annie.png', Single_blob) as img
-- declare a VARBINARY(MAX) variable to hold the "Desc Audio" and load it
DECLARE @DescAudio VARBINARY(MAX)
SELECT @DescAudio = BulkColumn
FROM Openrowset (bulk 'H:\Data\D\11-image\aa.wav' Single_blob) as img
-- declare a VARBINARY(MAX) variable to hold the "Sound" and load it
DECLARE @Sound VARBINARY(MAX)
SELECT @Sound = BulkColumn
FROM Openrowset (bulk 'H:\Data\D\ll-image\a.wav', Single_blob) as img
-- now do the INSERT with all bits ready to go
INSERT INTO dbo.Letterland (letter, letterImage, letterDescAudio, letterSound)
VALUES ('a', @Image, @DescAudio, @Sound)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.