Moderatori: Anthony47, Triumph Of Steel, archimede
:?: Hai provato ad usare la barra di scorrimento laterale del browser?albebigio ha scritto:bisogna registrarsi per vedere la soluzione
albebigio ha scritto:Scusate tanto la mia incapacità ma non riesco proprio a trovarlo; mi potreste dare il link della pagina con la soluzione o copiarla e incollarla direttamente?
1) If you are using an ADODB.Recordset to UPDATE / INSERT (e.g. using the AddNew method), use a direct SQL statement instead
A quick note: NEVER store a recordset in the session object. For a discussion of this see:
http://www.microsoft.com/mind/1198/ado/ado.htm
http://support.microsoft.com/?kbid=176056
Most data access tasks can be implemented by using the execute method of the connection object. Why would we want to do this? Well, for one, there is extra overhead in using a recordset object for UPDATE and INSERT functionality. This is because the provider has to translate your code into an equivalent T-SQL statement anyway (the database itself has no knowledge of "addNew" and similar methods). Also, there are many dangerous locks associated with recordsets... most of which are not necessary (especially when performing an INSERT or UPDATE). Your goal should be to get in, tweak your data, and get out as quickly as possible. Using direct statements is the quickest way to do this, since there is much less overhead and no locks associated with your activity.
Another benefit of using an INSERT or UPDATE statement is that it is much easier to debug. You can change conn.execute(sql) to response.write(sql) and immediately see why your statement is throwing an error. With a multi-line transaction using a recordset object, it is translated to an INSERT or UPDATE statement (inefficient!) on the DB side, so there is no straightforward way to trap errors at the code level.
To use the connection object, simply design a transact-SQL statement for the action you want to use and implement it like so:
<%
sql = "INSERT INTO <table> (fields) VALUES (values)"
set conn = Server.CreateObject("ADODB.Connection")
conn.open "<connection string>"
conn.execute sql, , 129
' 129 is the constant for adExecuteNoRecords + adCmdText
...
%>
VLC - unire file .mts della videocamera Autore: valyfilm |
Forum: Audio/Video e masterizzazione Risposte: 2 |
Macro che scatta quando cambia dato in un altro file Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 16 |
Salvare file excel in formato html escludendo le immagini Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 10 |
Modifica visualizzazione file di una cartella Autore: mastino46 |
Forum: Sistemi Operativi Windows Risposte: 2 |
Problema con macro copia e rinomina file Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 2 |
Visitano il forum: Nessuno e 5 ospiti