ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

سوال ذخیره و بازیابی تصویر از اکسس در vs.net

 
Post new topic   Reply to topic    ParsX.com Forum Index -> ASP C# .NET & PHP
View previous topic :: View next topic  
Author Message
sinaweb
مهمون يكي دو روزه


Joined: 25 Jul 2007
Posts: 2

PostPosted: Wed Jul 25, 2007 8:40 pm    Post subject: سوال ذخیره و بازیابی تصویر از اکسس در vs.net Reply with quote

سوال1 : چگونه می توان در ویژوال دات نت تصویری را در دیتا بیس ذخیره کرد ؟
سوال 2: چگونه می توان تصویر را از بانک فراخوانی کرد و در صفحه نمایش داد؟

*** دیابیس ما اکسس می باشد***
Back to top
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 3067
Location: Tehran

PostPosted: Fri Jul 27, 2007 8:31 am    Post subject: Reply with quote

از چه زباني استفاده مي كني ؟
ورژن vs شما چيست ؟
Back to top
sinaweb
مهمون يكي دو روزه


Joined: 25 Jul 2007
Posts: 2

PostPosted: Mon Jul 30, 2007 8:17 pm    Post subject: Reply with quote

ورژن vs من 2005 هست و مي خوام vb استفاده كنم

لطفا هرچه سريعتر روش رو به من بگيد
Back to top
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 3067
Location: Tehran

PostPosted: Tue Jul 31, 2007 9:14 pm    Post subject: Reply with quote

براي ذخيره تصوير :

Private Sub btnSave_Click(ByVal sender As System.Object, _
                          ByVal e As System.EventArgs) Handles btnSave.Click
  Dim oConn As OleDb.OleDbConnection
  Dim oComm As OleDb.OleDbCommand
  Dim Err As String
  Dim sInsertQuery As String
  Dim FSO As New System.IO.FileStream(imgFile.FileName, _
                                      IO.FileMode.Open, IO.FileAccess.Read)
  Try
  sInsertQuery = "insert into images([image]) VALUES(?)"
 
  oConn = New OleDb.OleDbConnection( _
          New Connection().getConnectionString)
  oConn.Open()
  oComm = New OleDb.OleDbCommand(sInsertQuery, oConn)
  Dim imgArrayByte(CType(FSO.Length() - 1, Integer)) As Byte
  FSO.Read(imgArrayByte, 0, imgArrayByte.Length)
  FSO.Close()
 
  Dim QueryParameter As New OleDb.OleDbParameter("@Picture", _
                                                 OleDb.OleDbType.LongVarBinary, _
                                                 imgArrayByte.Length, ParameterDirection.Input, _
                                                 False, 0, 0, Nothing, DataRowVersion.Current, _
                                                 imgArrayByte)
  oComm.Parameters.Add(QueryParameter)
  oComm.ExecuteNonQuery()
  MsgBox("Image is saved successfully to the Database", _
         MsgBoxStyle.OKOnly, _
         "Successfully Saved")
  getListOfImages()
  btnSave.Enabled = False
  Catch Ex As Exception
  Err = Ex.Message
  MsgBox("Error : " & Err, _
         MsgBoxStyle.OKOnly, "Error Occured")
  Finally
  oConn = Nothing
  oComm = Nothing
  End Try
End Sub

براي بازيابي تصوير

Private Sub cmbImgIds_SelectedIndexChanged(ByVal sender As System.Object, _
                                           ByVal e As System.EventArgs) Handles cmbImgIds.SelectedIndexChanged
  btnDelete.Enabled = False
  Dim sQuery As New System.Text.StringBuilder()
  Dim oDataTable As New DataTable()
  Dim dtRow As DataRow
  Dim imagedata() As Byte
  Dim imageBytedata As MemoryStream
  sQuery.Append("SELECT image FROM images WHERE imageId = " & _
                cmbImgIds.SelectedItem)
  oDataTable = New Connection().doDBconnection(sQuery.ToString, "Image")
 
  For Each dtRow In oDataTable.Rows
    btnDelete.Enabled = True
    imagedata = dtRow.Item("image")
    imageBytedata = New MemoryStream(imagedata)
  Next
  picBox.Image = Image.FromStream(imageBytedata)
End Sub
Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> ASP C# .NET & PHP All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum