hi all, I am having a problem with importing images into Database with code.
I've done this so far

        Dim conn As New Data.SqlClient.SqlConnection("Data Source=virtualmachinelink,1433;Network Library=DBMSSOCN;Initial Catalog=School Management;User ID=me;Password=mypass")
        'dont worry about the connection string, is good,
        Dim SDA As New SqlDataAdapter

        Dim bSource As New BindingSource

            Dim Query As String
            Query = "INSERT INTO Studenti (ID, Emri, Mbiemri, Gjinia, Datelindja, Shkolla, Klasa, Viti, Qarku, Email, Cel, ProfilePic, IDPic) values ('" & FlatTextBox1.Text & "','" & FlatTextBox2.Text & "','" & FlatTextBox3.Text & "','" & FlatTextBox4.Text & "','" & FlatTextBox5.Text & "','" & FlatTextBox6.Text & "','" & FlatTextBox7.Text & "','" & FlatTextBox8.Text & "','" & FlatTextBox9.Text & "','" & FlatTextBox10.Text & "','" & FlatTextBox11.Text & "','" & TextProfilePic.Text & "','" & TextIDPic.Text & "')"
            Command = New SqlCommand(Query, conn)
            SDA.SelectCommand = Command
            bSource.DataSource = dbDataSet

        Catch ex As SqlException
        End Try

I've created 2 columns. 1- ProfilePic, 2-IDcardPic
both set as 'Image' (could not find blob)

any suggestion?

I am having problem with importing those two in.

PS: FlatTextbox is just normal textbox. but is called like that from a design UI I am using.

If the column it's an image you can't add text to it, you need to parse to a byte array.

If you have an base64 image string for example, you can call byte[] toDecodeByte = Convert.FromBase64String(data);

Anyway, you shouldn't be using Image column, use varbinary(MAX) instead.
From Microsoft:

ntext , text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.

And besides that, you shouln't be storing images on the database anyway.
The best approch is to store the image on the hard disk and only store it's path on the database.

This article has been dead for over six months. Start a new discussion instead.