B
Bjørn Nornes
Reading file from disk (jpg)
Dim fi As New FileInfo(workFolder + CStr(mmgcid) + ".jpg")
Dim fs As FileStream = fi.OpenRead()
Dim nBytes As Integer = fi.Length
Dim ByteArray(nBytes) As Byte
Dim nBytesRead As Integer = fs.Read(ByteArray, 0, nBytes)
Dim WebServices As mediaService.Service1 = New mediaService.Service1
Dim retstatus As String
Using WEB service to update SQL database
retstatus = WebServices.UpdateThumbFileBlob(mmgcid, ByteArray)
public string UpdateThumbFileBlob(int MediaID, byte[] mmfbBlobThumb)
{
SqlConnection Connection = new
SqlConnection("SERVER=localhost;DATABASE=db1;UID=user;PWD=pwd");
String updateCmd = "UPDATE MultiMediaFileBlobs SET mmfbBlobThumb
=@mmfbBlobThumb where mmfbId=" + MediaID;
SqlCommand myCommand = new SqlCommand(updateCmd, Connection);
SqlParameter StatusParameter = new SqlParameter("@mmfbBlobThumb",
SqlDbType.Image);
StatusParameter.Value = mmfbBlobThumb;
myCommand.Parameters.Add(StatusParameter);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
}
However record is not updated ?
Anyone who sees any problems with my code here ?
regards
BN
Dim fi As New FileInfo(workFolder + CStr(mmgcid) + ".jpg")
Dim fs As FileStream = fi.OpenRead()
Dim nBytes As Integer = fi.Length
Dim ByteArray(nBytes) As Byte
Dim nBytesRead As Integer = fs.Read(ByteArray, 0, nBytes)
Dim WebServices As mediaService.Service1 = New mediaService.Service1
Dim retstatus As String
Using WEB service to update SQL database
retstatus = WebServices.UpdateThumbFileBlob(mmgcid, ByteArray)
public string UpdateThumbFileBlob(int MediaID, byte[] mmfbBlobThumb)
{
SqlConnection Connection = new
SqlConnection("SERVER=localhost;DATABASE=db1;UID=user;PWD=pwd");
String updateCmd = "UPDATE MultiMediaFileBlobs SET mmfbBlobThumb
=@mmfbBlobThumb where mmfbId=" + MediaID;
SqlCommand myCommand = new SqlCommand(updateCmd, Connection);
SqlParameter StatusParameter = new SqlParameter("@mmfbBlobThumb",
SqlDbType.Image);
StatusParameter.Value = mmfbBlobThumb;
myCommand.Parameters.Add(StatusParameter);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
}
However record is not updated ?
Anyone who sees any problems with my code here ?
regards
BN