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