Link to home
Start Free TrialLog in
Avatar of Member_2_5230414
Member_2_5230414

asked on

ExecuteNonQuery: Connection property has not been initialized.

What is wrong with my command to get ExecuteNonQuery: Connection property has not been initialized.

  Shared Function editpost(ByVal id As Integer, ByVal title As string, ByVal post As String, ByVal important As String, ByVal forumlock As String) As String

        Using con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\perkinj\My Documents\Visual Studio 2010\WebSites\runningprofiles\forums\forum.mdb")
            Dim cmd As New OleDbCommand
            con.Open()

            cmd.CommandText = "UPDATE forum (Title,Post,forumlock,important) VALUES ('" & title & "','', '" & post & "','" & important & "','" & forumlock & "') where ID = '" & id & "'"

            cmd.ExecuteNonQuery()
            con.Close()
        End Using

    End Function

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_5230414
Member_2_5230414

ASKER

Syntax error in UPDATE statement.

 cmd.CommandText = "UPDATE forum (Title,Post,forumlock,important) VALUES ('" & title & "','" & post & "','" & important & "','" & forumlock & "') where ID = '" & id & "'"

Open in new window