---
title: "problem med att spara data till ms databas"
type: "forum-thread"
url: "https://www.webforum.nu/amne/databaser-sql/182249-problem-med-att-spara-data-till-ms-databas"
topic: "Databaser & SQL"
topic_url: "https://www.webforum.nu/amne/databaser-sql"
author: "EndLessMind"
published: "2010-01-31T21:25:07.000Z"
updated: "2010-01-31T21:25:07.000Z"
replies: 0
views: 363
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/databaser-sql/182249-problem-med-att-spara-data-till-ms-databas"
---

# problem med att spara data till ms databas

## #1 — EndLessMind, 2010-01-31T21:25Z

Hej.
När jag försöker ändra informationen i en rad så får jag detta:

"Syntaxfel (operator saknas) i frågeuttrycket '((ID = ?) AND ((? = 1 AND Förnamn IS NULL) OR (Förnamn = ?)) AND ((? = 1 AND Efternamn IS NULL) OR (Efternamn = ?)) AND ((? = 1 AND Gatuadress IS NULL) OR (Gatuadress = ?)) AND ((? = 1 AND Postnummer IS NULL) OR (Postnummer = ?)) AND ((? = 1 AND Stad IS N'."

och när ja försöker skapa en nya rad så får jag detta:

"Syntaxfel i INSERT INTO-uttryck."

detta händer när ja försöker spara. 
Någon som vet varför?
här e koden för "spara" händelsen 

```
If My.Settings.chang = True Then
            Dim cb As New OleDb.OleDbCommandBuilder(da)
            ds.Tables("Database2").Rows(inc).Item(1) = txtfm.Text
            ds.Tables("Database2").Rows(inc).Item(2) = txtem.Text
            ds.Tables("Database2").Rows(inc).Item(3) = txtga.Text
            ds.Tables("Database2").Rows(inc).Item(4) = txtpn.Text
            ds.Tables("Database2").Rows(inc).Item(5) = txts.Text
            ds.Tables("Database2").Rows(inc).Item(6) = txttm.Text
            ds.Tables("Database2").Rows(inc).Item(7) = txtth.Text
            ds.Tables("Database2").Rows(inc).Item(8) = txtma.Text
            ds.Tables("Database2").Rows(inc).Item(9) = txta1.Text
            ds.Tables("Database2").Rows(inc).Item(10) = txtpc.Text
            ds.Tables("Database2").Rows(inc).Item(11) = txtgf.Text
            ds.Tables("Database2").Rows(inc).Item(12) = cmba.Text
            ds.Tables("Database2").Rows(inc).Item(13) = txthd.Text
            ds.Tables("Database2").Rows(inc).Item(14) = cmbmt.Text
            ds.Tables("Database2").Rows(inc).Item(15) = cmbop.Text
            ds.Tables("Database2").Rows(inc).Item(16) = cmbdl.Text
            ds.Tables("Database2").Rows(inc).Item(17) = txtn.Text
            ds.Tables("Database2").Rows(inc).Item(18) = txttmf.Text
            ds.Tables("Database2").Rows(inc).Item(19) = txtthf.Text
            ds.Tables("Database2").Rows(inc).Item(20) = txtgaf.Text
            ds.Tables("Database2").Rows(inc).Item(21) = txtpnf.Text
            ds.Tables("Database2").Rows(inc).Item(22) = txtsf.Text
            ds.Tables("Database2").Rows(inc).Item(23) = txta2.Text
            ds.Tables("Database2").Rows(inc).Item(24) = txtsb.Text
            ds.Tables("Database2").Rows(inc).Item(25) = txtmr.Text
            ds.Tables("Database2").Rows(inc).Item(26) = txtp.Text
            ds.Tables("Database2").Rows(inc).Item(27) = txtep.Text
            da.Update(ds, "Database2")
            MsgBox("Data updated")
        ElseIf My.Settings.chang = False Then
            If inc <> -1 Then

                Dim cb As New OleDb.OleDbCommandBuilder(da)
                Dim dsNewRow As DataRow

                dsNewRow = ds.Tables("Database2").NewRow()

                dsNewRow.Item(1) = txtfm.Text
                dsNewRow.Item(2) = txtem.Text
                dsNewRow.Item(3) = txtga.Text
                dsNewRow.Item(4) = txtpn.Text
                dsNewRow.Item(5) = txts.Text
                dsNewRow.Item(6) = txttm.Text
                dsNewRow.Item(7) = txtth.Text
                dsNewRow.Item(8) = txtma.Text
                dsNewRow.Item(9) = txta1.Text
                dsNewRow.Item(10) = txtpc.Text
                dsNewRow.Item(11) = txtgf.Text
                dsNewRow.Item(12) = cmba.Text
                dsNewRow.Item(13) = txthd.Text
                dsNewRow.Item(14) = cmbmt.Text
                dsNewRow.Item(15) = cmbop.Text
                dsNewRow.Item(16) = cmbdl.Text
                dsNewRow.Item(17) = txtn.Text
                dsNewRow.Item(18) = txttmf.Text
                dsNewRow.Item(19) = txtthf.Text
                dsNewRow.Item(20) = txtgaf.Text
                dsNewRow.Item(21) = txtpnf.Text
                dsNewRow.Item(22) = txtsf.Text
                dsNewRow.Item(23) = txta2.Text
                dsNewRow.Item(24) = txtsb.Text
                dsNewRow.Item(25) = txtmr.Text
                dsNewRow.Item(26) = txtp.Text
                dsNewRow.Item(27) = txtep.Text

                ds.Tables("Database2").Rows.Add(dsNewRow)

                da.Update(ds, "Database2")

                MsgBox("New Record added to the Database")
                My.Settings.chang = True
                'btnCommit.Enabled = False
                'btnAddNew.Enabled = True
                'btnUpdate.Enabled = True
                'btnDelete.Enabled = True

            End If
        End If
```

Tack på förhand :)

Permalänk: https://www.webforum.nu/p/182249

---

Tråden på webben: https://www.webforum.nu/amne/databaser-sql/182249-problem-med-att-spara-data-till-ms-databas
