|
ABAboi
|
Its actually a straight forward process. Follow the following steps. However the following codes basically scans your computer for .JPEG file extensions and adds them direct to your SQLSERVER. But ofcourse u can decide to import the image in a picture box control prior saving it in the database. Create a table named "ImageData"Its attributess are
Name (varChar50) Picture (Image) CreateDate(varChar20)--'NOT REALLY NECCESSARY
Now in your Form, You will need 2 buttons named btnSave and BtnSearch, textbox (txtName)
For the clicked event of btnSearch, add these codes Dim pictureLocation As String Dim a As New OpenFileDialog a.Filter = ("Image files| *.JPG") pictureLocation = a.FileName a.ShowDialog() Using conn As New System.Data.SqlClient.SqlConnection("Data Source=DENSMAN-PC\SQLEXPRESS;Initial Catalog=aba;Integrated Security=True") 'Insert your connection string here conn.Open()
Using cmd As New SqlClient.SqlCommand("Insert Into ImageData(Name, CreateDate, Picture) Values (@Name, @CreateDate, @Picture)", conn) cmd.Parameters.Add(New SqlClient.SqlParameter("@Name", SqlDbType.VarChar)).Value = txtName.Text cmd.Parameters.Add(New SqlClient.SqlParameter("@CreateDate", SqlDbType.VarChar)).Value = DateTime.Today cmd.Parameters.Add(New SqlClient.SqlParameter("@Picture", SqlDbType.Image)).Value = IO.File.ReadAllBytes(a.FileName) cmd.ExecuteNonQuery() End Using
End Using When you are done with the following, i can tell u other ways to modify and optimise your programme, then i will give u the second part once u get this working. Cheers
|