---
title: "Hur många nya och uppdaterade poster"
type: "forum-thread"
url: "https://www.webforum.nu/amne/asp/145900-hur-många-nya-och-uppdaterade-poster"
topic: "ASP"
topic_url: "https://www.webforum.nu/amne/asp"
author: "devotion"
published: "2006-04-23T06:51:23.000Z"
updated: "2006-04-23T11:01:57.000Z"
replies: 2
views: 320
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/asp/145900-hur-många-nya-och-uppdaterade-poster"
---

# Hur många nya och uppdaterade poster

## #1 — devotion, 2006-04-23T06:51Z

Hej!

Hur får jag fram informationen om hur många poster som uppdaterades respektive lades till?

Har följande kod:

```
					'Uppdatera tblArticle om artikeln redan finns
					sSQL = "UPDATE tblArticle SET articleNumber = '" & sEnumber & "', articleName = '" & sArticleName & "', articleUnit = '" & sUnit & "' WHERE articleNumber = '" & sEnumber & "'"
					objConn.Execute sSQL, lngRA, 128
				
					if lngRa = 0 then
						'Lägga till artikeln i tblArticle om den inte finns
						sSQL = "INSERT INTO tblArticle (articleNumber, articleName, articleUnit) VALUES ('" & sEnumber & "', '" & sArticleName & "', '" & sUnit & "')"		
						objConn.Execute sSQL,,128
					End if
					
					'Uppdatera tblPrice om artikeln redan finns
					sSQL = 	"UPDATE tblPrice SET articleNumber = '" & sEnumber & "', articleSupplierId = " & iSupplierId & ", articlePrice = " & iPrice & ", " &_ 
							"articleCategoryNumber = '" & sCategory & "' WHERE articleNumber = '" & sEnumber & "' AND articleSupplierId = " & iSupplierId
							
					objConn.Execute sSQL, lngRA, 128
				
					if lngRA = 0 then
						'Lägga till artikeln i tblPrice om den inte finns
						sSQL =  "INSERT INTO tblPrice (articleNumber, articleSupplierId, articlePrice, articleCategoryNumber) " &_
								"VALUES ('" & sEnumber & "', " & iSupplierId & ", " & iPrice & ", '" & sCategory & "')"
						objConn.Execute sSQL,, 128
					End If
```

Mvh
Henrik

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

## #2 — @nders, 2006-04-23T08:01Z

Variabeln lngRA innehåller antalet poster som uppdaterades när du har kört dina SQL-frågor (när du har med den i execute-anropet).

Du får skapa ett par variabler i asp som du räknar med, typ:

```
[b]lUpdates = 0[/b]
[b]lInserts = 0[/b]

.......

'Uppdatera tblArticle om artikeln redan finns
sSQL = "UPDATE tblArticle SET articleNumber = '" & sEnumber & "', articleName = '" & sArticleName & "', articleUnit = '" & sUnit & "' WHERE articleNumber = '" & sEnumber & "'"
objConn.Execute sSQL, lngRA, 128

[b]lUpdates = lUpdates + lngRA[/b]

if lngRa = 0 then
'Lägga till artikeln i tblArticle om den inte finns
	sSQL = "INSERT INTO tblArticle (articleNumber, articleName, articleUnit) VALUES ('" & sEnumber & "', '" & sArticleName & "', '" & sUnit & "')"		
	objConn.Execute sSQL,,128
	[b]lInserts = lInserts + 1[/b]
End if

'Uppdatera tblPrice om artikeln redan finns
sSQL = 	"UPDATE tblPrice SET articleNumber = '" & sEnumber & "', articleSupplierId = " & iSupplierId & ", articlePrice = " & iPrice & ", " &_ 
		"articleCategoryNumber = '" & sCategory & "' WHERE articleNumber = '" & sEnumber & "' AND articleSupplierId = " & iSupplierId
		
objConn.Execute sSQL, lngRA, 128
[b]lUpdates = lUpdates + lngRA[/b]

if lngRA = 0 then
	'Lägga till artikeln i tblPrice om den inte finns
	sSQL =  "INSERT INTO tblPrice (articleNumber, articleSupplierId, articlePrice, articleCategoryNumber) " &_
			"VALUES ('" & sEnumber & "', " & iSupplierId & ", " & iPrice & ", '" & sCategory & "')"
	objConn.Execute sSQL,, 128
	[b]lInserts = lInserts + 1[/b]
End If
```

Jag passar också på att flytta tråden från SQL.

mvh

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

## #3 — devotion, 2006-04-23T11:01Z

Tackar!
Funkar finfint! :D 

Bra att du flyttade tråden.... Blev lite fel där...

Mvh
Henrik

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

---

Tråden på webben: https://www.webforum.nu/amne/asp/145900-hur-många-nya-och-uppdaterade-poster
