-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: sureshgona
Message 2 in Discussion
try
this
Dim cnnstr As
String
Dim
filePath As String
Dim cmd As
String
Dim fsBLOB As
FileStream
Dim svr As
SqlDataAdapter
Dim svrConn As
SqlConnection
Dim svrParams As
SqlParameter
cnnstr = "data
source=myserver;user id=myself;password=mypwd;initial
catalog=Photos"
filePath =
"D:\Photos\MyCar.jpg"
cmd =
"up_InsertPhoto"
'reading the JPEG file
fsBLOB = New FileStream(filePath, FileMode.Open,
FileAccess.Read)
Dim oBytes(fsBLOB.Length)
As Byte
fsBLOB.Read(oBytes, 0,
oBytes.Length)
fsBLOB.Close()
'connecting to
server
svrConn = New
SqlConnection(cnnstr)
svr = New
SqlDataAdapter(cmd, svrConn)
'set 1st param
svrParams = New SqlParameter("@photoclip_IM",
SqlDbType.VarBinary)
svrParams.Size =
oBytes.Length
svrParams.Value =
oBytes
svr.SelectCommand.Parameters.Add(svrParams)
'set 2nd
param
svrParams = New
SqlParameter("@photodesc_V", SqlDbType.NVarChar)
svrParams.Value = "My car photo"
svr.SelectCommand.Parameters.Add(svrParams)
'open server connection &
execute query
svrConn.Open()
svr.SelectCommand.ExecuteNonQuery()
You may notice using SqlDbType.VarBinary for SQL Server
Image data type, well if I replace the stored procedure with a string SQL
command,
cmd =
"INSERT INTO phototest (photodesc,photo) VALUES
(@photodesc,@photo)"
Then
replacing the parameter names repect to the above command... well it works. I
had a look at the MSDN KB article 317701 that why I used to BLOB and SQL DBtype
VarBinary,
Suresh
-----Original Message-----
From: r_sethu
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 11, 2004 6:18
PM
To: BDOTNET
Subject: Images in SQL Server
table
New Message on BDOTNET
Images in
SQL Server table
Reply
Reply to Sender Recommend
Message 1 in
Discussion
From: r_sethu
Hai everybody,
I have to store Images (JPG files) into SQL Server 2000
Database and at runtime I need to retrieve the images and
display into a picturebox. Please help me with VB.Net
sample code and table design query. I don't want to
store only file names but I want to store the image.
with regards,
Sethu.
View other groups in this
category.
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]