:e
Hej!
Jag har följande kod som är en aspfil:
<%
Dim sSQL, objConn, objRS1, objRS2, iStatus, sNote, sCategory, sName, sArtNr, sUnit, iPrice, iNextId, sArticleNumber, sArticleName, sList, iSupplierId
'Ange status; 0 = "synkroniserad med SPCS", 1 = "Inte synkroniserad mot SPCS"
iStatus = 0
'Notering
sNote = ""
'Pris
iPrice = 0
' Öppna databasen
' ***************
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = Application("sConn")
objConn.Open
sSQL = "SELECT tblArticle.articlenumber, tblArticle.articleName, tblArticle.articleUnit " &_
"FROM tblArticle " &_
"ORDER BY tblArticle.articlenumber"
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open sSQL, objConn, 3, 1
If not objRS1.EOF then
do while not objRS1.EOF
sArticleNumber = objRS1("articleNumber")
sArticleName = objRS1("articleName")
sUnit = lCase(objRS1("articleUnit"))
'Ta ut de två första tecknena i E-numret
sList = left(sArticleNumber, 2)
'Hämta kategorinamn mha sList
Set objRS2 = objConn.Execute ("SELECT listName FROM tblList WHERE listNr = '" & sList & "'")
If not objRS2.EOF then
sCategory = objRS2("listName")
End If
objRS2.Close
Set objRS2 = Nothing
Set objRS2 = objConn.Execute ("SELECT nextId FROM UppdragNu.dbo.tblNextId WHERE [table] = 'tblArticle'")
If not objRS2.EOF then
iNextId = cLng(objRS2("NextId"))
End If
objRS2.Close
Set objRS2 = Nothing
sSQL = "INSERT INTO UppdragNu.dbo.tblArticle ([Id], [Status], [Modified], [Nr], [Name], [Category], [Unit], [Price], [Note]) " &_
"VALUES(" & iNextId & ", " & iStatus & ", getdate(), '" & sArticleNumber & "', '" & sArticleName & "', " &_
"'" & sCategory & "', '" & sUnit & "', " & iPrice & ", '" & sNote & "')"
Response.write sSQL
'response.end
objConn.execute sSQL,,128
sSQL = "UPDATE UppdragNu.dbo.tblNextId SET nextId = nextId + 1 WHERE [Table] = 'tblArticle'"
objConn.Execute sSQL,, 128
objRS1.Movenext
Loop
Else
Response.write "Fel!"
End if
objRS1.Close
Set objRS1 = Nothing
Response.write "Datat har lagrats!"
%>
Nu skulle jag vilja göra om den till en vbscriptfil som är körbar i windows. Detta är helt nytt för mig, så jag skulle vara glad om någon kunde sparka mig i rätt riktning.... ;)
Var hittar jag vbScript-referenser?
Finns det någon bra bok?
Mvh
Henrik