Cool that worked, maybe you could help me with the overall problem also. I am trying to insert a picture into my database. Now that I have the invalid column name solved I have another error. The error is stating that I cannot insert a null into the column and I am sure that I'm not inserting a null type. Here is the code and the error is attached.

Public Sub Button2_Click(ByVal objSender As Object, ByVal objArgs As EventArgs)
        Dim intLength As Integer
        Dim ByteSize As Byte()
        
        Dim fileName As String = FileUpload1.PostedFile.FileName
        Dim imgType = FileUpload1.PostedFile.ContentType
        
        intLength = Int32.Parse(FileUpload1.PostedFile.InputStream.Length)
        
        ReDim ByteSize(intLength)
        
        FileUpload1.PostedFile.InputStream.Read(ByteSize, 0, intLength)
        
        Doc2SQLServer(ByteSize, intLength)
         
        
    End Sub
    
    Public Function Doc2SQLServer(ByVal Content As Byte(), ByVal Length As Integer) As Boolean
         
        Dim ConnString As String
        ConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\inetpub\wwwroot\KiKoGraphics\App_Data\aspnetdb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
        Dim sqlConn As New SqlConnection(ConnString)
        Dim sqlCom As New SqlCommand()
        sqlCom.Connection = sqlConn
        sqlCom.CommandText = "INSERT INTO ImageTable (DatabaseImage) VALUES (@Photo)"
        
        sqlCom.Parameters.Add("@Photo", Data.SqlDbType.Image)
        sqlCom.Parameters("@Photo").Value = Content
        
        sqlConn.Open()
        sqlCom.ExecuteNonQuery()
        sqlConn.Close()
    End Function

It's usually best practice to store the image name or location in the database and use that on your front-end to display the image. Is there a reason you can't do that in this instance?

Hey thanks for responding. I will have the image name and alot more other information stored with the image, But to understand the process of storing an image in a database the other information is not needed. Can you help me out?

Thanks in advance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.