Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > นำไฟล์รูปภาพใน SQL Server 2005 มาแสดงใน PictureBox VB.NET



 

นำไฟล์รูปภาพใน SQL Server 2005 มาแสดงใน PictureBox VB.NET

 



Topic : 063626



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์




รบกวนพี่ๆช่วยเเหลือหน่อยครับ คือผมเก็บไฟล์รูปภาพไว้ใน SQL Server 2005 โดยผ่านทาง PictureBox ของ VB.Net แต่เวลาจะนำรูปภาพที่เก็บไว้มาโชว์ใน PictureBox ตัวเดิม ต้องทำอย่างไรครับ เนื่องจากภาพถูกเก็บไว้เป็นแบบ System.Byte[]

Code (VB.NET)
Private Sub dgvEquipmentList_CellMouseclick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvEquipmentList.CellMouseClick
        If e.RowIndex = -1 Then Exit Sub
        With dgvEquipmentList    
            txtEqmID.Text = .Rows.Item(e.RowIndex).Cells(0).Value.ToString()
            txtEqmName.Text = .Rows.Item(e.RowIndex).Cells(1).Value.ToString()
            txtSize.Text = .Rows.Item(e.RowIndex).Cells(2).Value.ToString()
            txtWidth.Text = .Rows.Item(e.RowIndex).Cells(3).Value.ToString()
            txtLength.Text = .Rows.Item(e.RowIndex).Cells(4).Value.ToString()
            txtHigh.Text = .Rows.Item(e.RowIndex).Cells(5).Value.ToString()
            txtBalance.Text = .Rows.Item(e.RowIndex).Cells(6).Value.ToString()
            picEquipmentPicture.Image = 'ตรงนี้ต้องเขียนอย่างไร


ผมได้เข้าไปดูในกระทู้เก่าๆแล้วครับ แต่มันเป็นภาษา C# รบกวนพี่ๆช่วยแนะนำเป็น vb.net ด้วยนะครับขอบคุณมากครับ

ปล.สาเหตุที่เก็บไฟล์ภาพลงไปใน sql server ตรงๆเลย ก็เพราะผมเก็บรูปภาพอุปกรณ์เพียงแค่ 3 รูปเท่านั้นครับ



Tag : .NET, Ms SQL Server 2005, VB.NET







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2011-07-23 04:04:47 By : suvivor View : 8141 Reply : 7
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ลองดูกระทู้นี้ครับ

Code (VB.NET)
connection.Open();
SqlCommand command1 = new SqlCommand("select imgfile from myimages where imgname=@param", connection);
SqlParameter myparam = command1.Parameters.Add("@param", SqlDbType.NVarChar, 30);
myparam.Value = txtimgname.Text;
byte[] img = (byte[])command1.ExecuteScalar();
MemoryStream str = new MemoryStream();
str.Write(img, 0, img.Length);
Bitmap bit = new Bitmap(str);
Response.ContentType = "image/jpeg";
bit.Save(Response.OutputStream, ImageFormat.Jpeg);
connection.Close();


Go to : สอบถามวิธีการดึงรูปภาพที่บันทึกไว้(เป็น Binary data)ในฐานข้อมูลเอามาแสดงใน PictureBox ครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-07-23 08:33:39 By : webmaster
 


 

No. 2



โพสกระทู้ ( 616 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

มำไมไม่เก้บเป็นชื่อไฟล์รูปเอาอะครับ เวลาเรียกใช้น่าจะง่ายกว่านะครับ

Code (VB.NET)
With dgvEquipmentList 
PictureBox.ImageLocation = Application.StartupPath & "ชื่อ Folder\" & .Rows.Item(e.RowIndex).Cells(7).Value.ToString()
End With

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-07-23 21:38:05 By : slurpee55555
 

 

No. 3



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์


ขอโค๊ดที่บันทึกรูปทาง Picture Box ลง Database หน่อยจ้า VB น๊า
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-07-23 23:45:49 By : idearkung
 


 

No. 4



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ตอบความคิดเห็นที่ : 3 เขียนโดย : idearkung เมื่อวันที่ 2011-07-23 23:45:49
รายละเอียดของการตอบ ::
Code (VB.NET)
Private Sub Form1_Load(sender As Object, e As EventArgs)

End Sub

Private Sub button1_Click(sender As Object, e As EventArgs)
	Dim myWebClient As New WebClient()
	Dim fileName As String = textBox1.Text
	Dim _path As String = Application.StartupPath
	MessageBox.Show(_path)
	_path = _path.Replace("Debug", "Images")
	MessageBox.Show(_path)
	myWebClient.UploadFile(_path, fileName)
End Sub

Private Sub btnBrowse_Click(sender As Object, e As EventArgs)
	Dim ofDlg As New OpenFileDialog()
	ofDlg.Filter = "JPG|*.jpg|GIF|*.gif|PNG|*.png|BMP|*.bmp"
	If DialogResult.OK = ofDlg.ShowDialog() Then
		textBox1.Text = ofDlg.FileName
		button1.Enabled = True
	Else
		MessageBox.Show("Go ahead, select a file!")
	End If

End Sub

Private Sub textBox1_TextChanged(sender As Object, e As EventArgs)
	If textBox1.Text = "" Then
		button1.Enabled = False
	End If
End Sub


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-07-24 08:22:10 By : webmaster
 


 

No. 5



โพสกระทู้ ( 23 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 4 เขียนโดย : webmaster เมื่อวันที่ 2011-07-24 08:22:10
รายละเอียดของการตอบ ::
ขอบคุนค๊าฟ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-07-28 16:37:38 By : idearkung
 


 

No. 6



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณทุกความเห็นครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2011-08-11 16:34:51 By : suvivor
 


 

No. 7



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Code (VB.NET)
Using myConnection As New OleDbConnection(strConnection)
    myConnection.Open()
    Dim strSql As String = "SELECT PICTURE FROM MT_IMAGE"
    Try
        Using myCommand As New OleDbCommand(strSql, myConnection)
            myCommand.CommandType = CommandType.Text
            Using myDataReader As OleDbDataReader = myCommand.ExecuteReader()
                myDataReader.Read()
                Dim ImageBytes As Byte() = CType(myDataReader(0), Byte())
                Dim ms As New MemoryStream(ImageBytes)
                Dim img As Image = Image.FromStream(ms)
                picShow.Image = img
            End Using
        End Using
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Error")
    End Try
End Using

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-04-01 17:11:50 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : นำไฟล์รูปภาพใน SQL Server 2005 มาแสดงใน PictureBox VB.NET
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่