Click here to Skip to main content
16,005,181 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Compact and Repair Access database using vb.net 2005 without using COM objects Pin
Dave Kreskowiak30-Dec-08 3:54
mveDave Kreskowiak30-Dec-08 3:54 
Question[Message Deleted] Pin
Parag Raibagkar29-Dec-08 19:38
Parag Raibagkar29-Dec-08 19:38 
AnswerRe: Exporting data from vb form to HTML page Pin
Dave Kreskowiak30-Dec-08 3:48
mveDave Kreskowiak30-Dec-08 3:48 
Questionhow to display an image on Crystal report from a database Using VB.NET Pin
amna_elahi200229-Dec-08 18:36
amna_elahi200229-Dec-08 18:36 
AnswerRe: how to display an image on Crystal report from a database Using VB.NET Pin
Rupesh Kumar Swami29-Dec-08 22:33
Rupesh Kumar Swami29-Dec-08 22:33 
AnswerRe: how to display an image on Crystal report from a database Using VB.NET Pin
Tom Deketelaere29-Dec-08 22:34
professionalTom Deketelaere29-Dec-08 22:34 
AnswerRe: how to display an image on Crystal report from a database Using VB.NET Pin
Vikash Yadav30-Dec-08 3:33
Vikash Yadav30-Dec-08 3:33 
GeneralRe: how to display an image on Crystal report from a database Using VB.NET Pin
Rupesh Kumar Swami30-Dec-08 4:07
Rupesh Kumar Swami30-Dec-08 4:07 
hi vikas,
you can create image type field in database and store byte array into this field.Simple follow these steps

1. first of all i assume PictureBox1 hold the picture data. So use following statement

Dim PictureBox1Data As Byte()<br />
If PictureBox1.Image Is Nothing Then<br />
PictureBox1Data = Nothing<br />
Else<br />
PictureBox1Data = imageToByteArray(PictureBox1.Image)'See below this function<br />
End If


2.Now write the SQL query as following

Dim QueryText As String<br />
Dim QueryValue As String<br />
Dim command As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand()<br />
QueryText = "INSERT INTO Settings(PrintCompany,IsUploadLogo,LogoGraphic )"<br />
QueryValue = "Values(@PrintCompany, @IsUploadLogo,@LogoGraphic)"<br />
command.CommandText = QueryText & QueryValue


3. Supply Value to parameter which is in above query, as following

command.Parameters.Add("@PrintCompany", SqlDbType.TinyInt, 10).Value = True<br />
command.Parameters.Add("@IsUploadLogo", SqlDbType.TinyInt, 10).Value =True<br />
If Not PictureBox1Data Is Nothing Then<br />
command.Parameters.Add("@LogoGraphic", SqlDbType.Image, PictureBox1Data.Length).Value = PictureBox1Data<br />
Else<br />
command.Parameters.Add("@LogoGraphic", SqlDbType.Image, 0).Value = System.DBNull.Value<br />
End If


4. Execute query as following

command.ExecuteNonQuery()

step 1 to 4 read data of picture box,convert them byte array and store in related table.Step 1 use following function to convert an image into byte array

Public Function imageToByteArray(ByVal ImageIn As System.Drawing.Image) As Byte()<br />
Dim ms As MemoryStream = New MemoryStream()<br />
Dim FormatImage1 As Imaging.ImageFormat = ImageIn.RawFormat<br />
ImageIn.Save(ms, FormatImage1)<br />
'ImageIn.Save(ms, Imaging.ImageFormat.Bmp)<br />
Return ms.ToArray()<br />
End Function


hope this helps

Rupesh Kumar Swami
Software Developer,
Integrated Solution,
Bikaner (India)

My Company
Award: Best VB.NET article of June 2008: Create Column Charts Using OWC11

GeneralRe: how to display an image on Crystal report from a database Using VB.NET Pin
amna_elahi200231-Dec-08 19:25
amna_elahi200231-Dec-08 19:25 
GeneralRe: how to display an image on Crystal report from a database Using VB.NET Pin
amna_elahi200231-Dec-08 20:01
amna_elahi200231-Dec-08 20:01 
QuestionTelerik Controls Pin
Tauseef A29-Dec-08 18:00
Tauseef A29-Dec-08 18:00 
AnswerRe: Telerik Controls Pin
Dave Kreskowiak29-Dec-08 18:15
mveDave Kreskowiak29-Dec-08 18:15 
GeneralRe: Telerik Controls Pin
Tauseef A29-Dec-08 19:20
Tauseef A29-Dec-08 19:20 
GeneralRe: Telerik Controls Pin
Tom Deketelaere29-Dec-08 22:31
professionalTom Deketelaere29-Dec-08 22:31 
GeneralRe: Telerik Controls Pin
Tauseef A29-Dec-08 23:10
Tauseef A29-Dec-08 23:10 
GeneralRe: Telerik Controls Pin
Tom Deketelaere29-Dec-08 23:25
professionalTom Deketelaere29-Dec-08 23:25 
GeneralRe: Telerik Controls Pin
Colin Angus Mackay30-Dec-08 0:49
Colin Angus Mackay30-Dec-08 0:49 
GeneralRe: Telerik Controls Pin
Colin Angus Mackay30-Dec-08 0:45
Colin Angus Mackay30-Dec-08 0:45 
AnswerRe: Telerik Controls Pin
Colin Angus Mackay30-Dec-08 0:40
Colin Angus Mackay30-Dec-08 0:40 
GeneralRe: Telerik Controls Pin
Jon_Boy30-Dec-08 2:28
Jon_Boy30-Dec-08 2:28 
AnswerRe: Telerik Controls Pin
Dave Kreskowiak30-Dec-08 3:32
mveDave Kreskowiak30-Dec-08 3:32 
GeneralRe: Telerik Controls Pin
Colin Angus Mackay30-Dec-08 4:44
Colin Angus Mackay30-Dec-08 4:44 
GeneralRe: Telerik Controls Pin
Jon_Boy30-Dec-08 5:28
Jon_Boy30-Dec-08 5:28 
GeneralRe: Telerik Controls Pin
Dave Kreskowiak30-Dec-08 7:54
mveDave Kreskowiak30-Dec-08 7:54 
GeneralRe: Telerik Controls Pin
Jon_Boy30-Dec-08 7:58
Jon_Boy30-Dec-08 7:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.