cant insert a filepath into a access db?

jnash

Well-known member
Joined
Oct 20, 2006
Messages
111
Programming Experience
Beginner
hi there, i have this one issue when i try to insert a filename of a image into a access database, it errors saying it cant find the filepath?? is there another setting i need to insert this string?
thanks in advance



my code:
VB.NET:
 Public Sub imageSave()

        Dim x As Integer
        Dim ol As String
        Dim os As String
        Dim fl As String
        Dim sm As String
        Dim aid As String
        aid = "something"
        x = image.Count
        Dim i As Integer
        projectname = "new document"

        While i < x

            ol = image.Item(i).location().ToString
            os = image.Item(i).size().ToString
            fl = image.Item(i).ImageLocation().toString 
            sm = image.Item(i).SizeMode().ToString
            aid = image.Item(i).backcolor().ToString

            Dim cmd As New OleDb.OleDbCommand("INSERT INTO form (objectLocation,objectSize,fileLocation,sizeMode,animationID) VALUES (@ol,@os,@fl,@sm,@aid)", conn)

            cmd.Parameters.AddWithValue("@fo", ol)
            cmd.Parameters.AddWithValue("@fn", os)
            cmd.Parameters.AddWithValue("@bc", fl)
            cmd.Parameters.AddWithValue("@fo", sm)
            cmd.Parameters.AddWithValue("@fo", aid)

            cmd.Connection.Open()
            cmd.ExecuteNonQuery()
            cmd.Connection.Close()

            MsgBox("Added Form")


            i = i + 1
        End While
    
End Sub
 
what are the values youre trying to save?

i.e. what are the values of @ol,@os,@fl,@sm,@aid just before you Execute()?

Also, when coding, please put brackets after sub and function calls, and not after properties:

ol = image.Item(i).location().ToString
os = image.Item(i).size().ToString
fl = image.Item(i).ImageLocation().toString
sm = image.Item(i).SizeMode().ToString
aid = image.Item(i).backcolor().ToString

Should probably be:
ol = image.Item(i).Location.ToString()
os = image.Item(i).Size.ToString()
fl = image.Item(i).ImageLocation.ToString()
sm = image.Item(i).SizeMode.ToString()
aid = image.Item(i).BackColor.ToString()

This is so fuddy-duddies like me, from stricter programming languages, can tell whether youre accessing a property or calling a sub/func
(purple block in Intellisense = use brackets. White piece of paper = use no brackets, unless the property is an indexed one, like Item() )
 
Back
Top