Marcus Ohlsson

Marcus Ohlsson

  • NA
  • 14
  • 3.5k

Another problem with a OLEDB connection

Jul 29 2011 1:14 PM
I wonder why I can't use this code?: (It works fine when I use it as a update statement)

            Dim cmd As New OleDb.OleDbCommand("INSERT INTO Företag (Företag=@a0,ASWNr=@a1,Kat=@a2,Sektion=@a3,Adress=@a4,Adress2=@a5,Pnr=@a6,Padr=@a7,Land=@a8,Telnr=@a9,Faxnr=@a10,Valuta=@a11,VATnr=@a12,Anm=@a13 WHERE (Fk=@a14)) ", conn)
            cmd.Parameters.AddWithValue("@a0", Fföretag.Text)
            cmd.Parameters.AddWithValue("@a1", Fasw.Text)
            cmd.Parameters.AddWithValue("@a2", Kattegori)
            cmd.Parameters.AddWithValue("@a3", Fsektion.Text)
            cmd.Parameters.AddWithValue("@a4", Fadress1.Text)
            cmd.Parameters.AddWithValue("@a5", Fadress2.Text)
            cmd.Parameters.AddWithValue("@a6", Fpostnummer.Text)
            cmd.Parameters.AddWithValue("@a7", Fpostadress.Text)
            cmd.Parameters.AddWithValue("@a8", Fland.Text)
            cmd.Parameters.AddWithValue("@a9", Fväxelnummer.Text)
            cmd.Parameters.AddWithValue("@a10", Ffax.Text)
            cmd.Parameters.AddWithValue("@a11", Fvaluta.Text)
            cmd.Parameters.AddWithValue("@a12", Fvatnr.Text)
            cmd.Parameters.AddWithValue("@a13", Fanm.Text)


            cmd.Parameters.AddWithValue("@a14", Företagsförkortning)
            cmd.ExecuteNonQuery()

In the begin of this project I have defined "conn" as a OleDbConnection (msaccess database) and I have used it many times before so I know it should work :-)



Sorry, I found the problem.