Click here to Skip to main content
15,885,914 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: phone book in network Pin
Jon_Boy24-Oct-08 1:09
Jon_Boy24-Oct-08 1:09 
GeneralRe: phone book in network Pin
Ashfield24-Oct-08 1:44
Ashfield24-Oct-08 1:44 
Questionthumnails image Pin
Member 264536523-Oct-08 21:42
Member 264536523-Oct-08 21:42 
AnswerRe: thumnails image Pin
Member 264536524-Oct-08 3:34
Member 264536524-Oct-08 3:34 
GeneralRe: thumnails image Pin
Ashfield24-Oct-08 5:17
Ashfield24-Oct-08 5:17 
Questionresize image and save in sql Pin
Member 264536523-Oct-08 21:39
Member 264536523-Oct-08 21:39 
AnswerRe: resize image and save in sql Pin
Eduard Keilholz23-Oct-08 22:00
Eduard Keilholz23-Oct-08 22:00 
AnswerRe: resize image and save in sql Pin
Rupesh Kumar Swami23-Oct-08 22:28
Rupesh Kumar Swami23-Oct-08 22:28 
Eduard already answered for resize image.
so for save an image in SQL server, first convert the image into byte array and then store in database field which is image type. Follow following 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: resize image and save in sql Pin
Member 264536524-Oct-08 0:00
Member 264536524-Oct-08 0:00 
GeneralRe: resize image and save in sql Pin
Eddy Vluggen24-Oct-08 0:39
professionalEddy Vluggen24-Oct-08 0:39 
Questiondiffernce betwen Me.Close() and Me.Dispose() Pin
vijaylumar23-Oct-08 20:50
vijaylumar23-Oct-08 20:50 
AnswerRe: differnce betwen Me.Close() and Me.Dispose() Pin
~Khatri Mitesh~23-Oct-08 21:41
~Khatri Mitesh~23-Oct-08 21:41 
GeneralRe: differnce betwen Me.Close() and Me.Dispose() Pin
N a v a n e e t h23-Oct-08 22:31
N a v a n e e t h23-Oct-08 22:31 
AnswerRe: differnce betwen Me.Close() and Me.Dispose() Pin
N a v a n e e t h23-Oct-08 22:32
N a v a n e e t h23-Oct-08 22:32 
AnswerRe: differnce betwen Me.Close() and Me.Dispose() PinPopular
Daniel Grunwald23-Oct-08 23:05
Daniel Grunwald23-Oct-08 23:05 
QuestionHow to Serializable OracleConnection Pin
lucdt23-Oct-08 18:07
lucdt23-Oct-08 18:07 
AnswerRe: How to Serializable OracleConnection Pin
Dave Kreskowiak24-Oct-08 1:35
mveDave Kreskowiak24-Oct-08 1:35 
GeneralRe: How to Serializable OracleConnection Pin
lucdt24-Oct-08 17:38
lucdt24-Oct-08 17:38 
AnswerRe: How to Serializable OracleConnection Pin
Wendelius24-Oct-08 7:59
mentorWendelius24-Oct-08 7:59 
GeneralRe: How to Serializable OracleConnection Pin
Anh trang24-Oct-08 17:29
Anh trang24-Oct-08 17:29 
Questionupdating database through datagrid - HELP PLEASE! Pin
libbypop23-Oct-08 17:44
libbypop23-Oct-08 17:44 
AnswerRe: updating database through datagrid - HELP PLEASE! Pin
Johan Hakkesteegt24-Oct-08 0:41
Johan Hakkesteegt24-Oct-08 0:41 
QuestionData validation in a textbox Pin
saypokguy23-Oct-08 14:03
saypokguy23-Oct-08 14:03 
AnswerRe: Data validation in a textbox Pin
Rupesh Kumar Swami23-Oct-08 20:50
Rupesh Kumar Swami23-Oct-08 20:50 
AnswerRe: Data validation in a textbox Pin
Wendelius24-Oct-08 8:20
mentorWendelius24-Oct-08 8:20 

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.