Imports System.Data.SqlClient Imports System Imports System.Data Imports System.Drawing Imports System.Drawing.Imaging Imports System.IO Imports Microsoft.VisualBasic Public Class Form1 Dim cn As New SqlConnection("Data Source=NIDA-PC\SQLEXPRESS;Initial Catalog=Finaldb;Integrated Security=True") Dim da As New SqlDataAdapter Dim ds As New DataSet Dim ms As New MemoryStream Dim cmd As New SqlCommand Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage PictureBox1.BackgroundImage = Image.FromFile(OpenFileDialog1.FileName) End If End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub Dim n As Integer Dim Photo_aray As Byte Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click cn.Open() cmd.CommandText = "Insert into Image_tbl(Image_ID,Photos)Values('" & TextBox1.Text & "','" & OpenFileDialog1.FileName & "')" cmd.Connection = cn Int(n = cmd.ExecuteNonQuery()) MsgBox("insert Image successfully") cn.Close() End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)