|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to save iamge in database?Can anyone tell me how to save an JPEG image in a database table field? Below is the code that I have wrote but it gives an error: System.InvalidCastException Object must implement IConvertible DatabaseAccess.SqlConnection.Open() picDataAdapter.InsertCommand = New SqlCommand("INSERT INTO TheImage(AppNo, theImage) VALUES(@appno, @theImage)", DatabaseAccess.SqlConnection) picDataAdapter.InsertCommand.Parameters.Add("@appno", SqlDbType.Int).Value = AppNo picDataAdapter.InsertCommand.Parameters.Add("@theImage", SqlDbType.Image, 7000).Value = MyImage picDataAdapter.InsertCommand.ExecuteNonQuery() DatabaseAccess.SqlConnection.Close() TheImage table has two fields: AppNo int theImage Image myImage is of Image type Waiting for reply... Thanks in advance Regards Ishtiaque Ahmed Memon Hi,
You need to convert the image to a byte array to save it in a database. There is an example in this tip. http://www.vb-tips.com/dbpages.aspx?ID=0bf3f72d-b722-459d-8a46-38b5a2f7fdf0 Ken ------------------- Show quoteHide quote "Ishtiaque Ahmed Memon" <ishtiaqu***@yahoo.com> wrote in message news:ObxCnnGtGHA.1304@TK2MSFTNGP06.phx.gbl... > Dear All > > Can anyone tell me how to save an JPEG image in a database table field? > > Below is the code that I have wrote but it gives an error: > System.InvalidCastException > Object must implement IConvertible > > DatabaseAccess.SqlConnection.Open() > > picDataAdapter.InsertCommand = New SqlCommand("INSERT INTO TheImage(AppNo, > theImage) VALUES(@appno, @theImage)", DatabaseAccess.SqlConnection) > > picDataAdapter.InsertCommand.Parameters.Add("@appno", SqlDbType.Int).Value > = > AppNo > > picDataAdapter.InsertCommand.Parameters.Add("@theImage", SqlDbType.Image, > 7000).Value = MyImage > > picDataAdapter.InsertCommand.ExecuteNonQuery() > > DatabaseAccess.SqlConnection.Close() > > TheImage table has two fields: > > AppNo int > > theImage Image > > myImage is of Image type > > Waiting for reply... Thanks in advance > > Regards > > Ishtiaque Ahmed Memon > > > > >
How to change printer's physical print margins thru VB coding?
2 pieces of the same code doing different things Custom Attributes, Shared methods, Derived classes and reflection allowing just numeric value in my textbox *** HELP *** Problems Accessing Simple VB.NET Access Database Cross-thread operation not valid How to validate Date entries. Placing a .lnk file on the desktop Wanted: Simple VB.NET "WEB" Application with an Access Database String translation |
|||||||||||||||||||||||