Re: update table with the word Null



Joe T wrote:
Here's the code:
<snip>
Recordset1_cmd.ActiveConnection = MM_stellco_STRING

This is a horrible coding practice. You need to get away from using
Dreamweaver and learn to code without that crutch. Your current problem
illustrates why I say that (see below).
The reason this is horrible is, because it forces ADO to create a new
connection behind the scenes, it kills performance by disabling connection
pooling. Best practices include creating an explicit Connection object in
your page and using it for your recordset and Command objects that you
create later on in the page. Like this:

Dim cn
Set cn = CreateObject("adodb.connection")
cn.open MM_stellco_STRING
....
Set Recordset1_cmd.ActiveConnection = cn


<snip>
<%
UPDATE projects
SET floorplan = "Null"
WHERE floorplan = ""
%>

OK, here is the problem with using Dreamweaver to generate bad code: you
never learn how to write code, good or otherwise, yourself. Vbscript will
not run a sql statement in a database on its own. It needs some help from
ADO, specifically from an ADO Command object. Like this:

Dim sql
sql=UPDATE projects SET floorplan = 'Null' WHERE floorplan =''"
'for debugging:
Response.Write sql
'comment out the above line when finished debugging
dim cmd
set cmd=createobject("adodb.command")
With cmd
.CommandText=sql
.CommandType = 1 'adCmdText
Set .ActiveConnection=cn 'see above
.Execute ,,128 'adExecuteNoRecords
End With
cn.close: set cn=nothing

In this case, since there are no parameters, you don't need to explicitly
create the Command object, you can use the Connection's Execute method which
will cause a Command object to be created implicitly behind the scenes:

Dim sql
sql=UPDATE projects SET floorplan = 'Null' WHERE floorplan =''"
'for debugging:
Response.Write sql
'comment out the above line when finished debugging
cn.Execute sql,,129 'adCmdText + adExecuteNoRecords

Again, I suggest you take a look at the links I provided in my previous
message.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: ADODC error message
    ... Command Text was not set for the command object" message! ... Dim SQL As String ...
    (microsoft.public.vb.database.ado)
  • ADODC error message
    ... Command Text was not set for the command object" message! ... Dim SQL As String ...
    (microsoft.public.vb.database.ado)
  • RE: Creating Procedure in SQL script through command object in VB.net
    ... I have not played with running lengthy scripts through a command object ... > I have a huge SQL script> which creates tables, ... > " Must declare the variable @vchProperty" ... > declare @iReturn int ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Storing calculated values... Exception!
    ... Dim sql As String ... sql = "SELECT ssDate, ssExpectedDate, ssCompletion, ssAlgorithm ... I am looking to store some calculated values (don't flame just yet, ...
    (comp.databases.ms-access)
  • Re: recordset.clone
    ... Dim SQL As String ... moment i open my form with the subform it applieas already the filters... ...
    (microsoft.public.access.formscoding)