UPDATE SQL

S

skc

In my "code view" I have a custom SQL (DRW) that updates a
database based on values from the previous page. I have
two asp pages...Page 1 is a form, Page 2 is a DRW with the
code shown below:

s-sql="UPDATE Job_test SET OperativeID='::OperativeID::',
Account_Details_Job_No='::Account_Details_Job_No::'
,
Account_Details_Date_Issued='::Account_Details_Date
_Issued::',
Account_Details_Date_of_Job='::Account_Details_Date
_of_Job::',
Account_Details_Acc_No='::Account_Details_Acc_No::
WHERE JobID=::JobID::"

I keep getting the error message:

----------------------

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver]
Syntax error in UPDATE statement.
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

One or more form fields were empty. You should provide
default values for all form fields that are used in the
query.

-------------------------

Not all the fields on the previuous page as filled in - as
they are non-mandatory.

What can I do to make this work?

skc
 
D

David Berry

If your database requires a value in the field then you need to check the
data being sent from the form and if it's empty you need to substitute a
bank "" or a NULL.
 
S

skc

My database does not reuqire a value as the fields can be
blank.

I do not understand what you mean - can you repeat please.
-----Original Message-----
If your database requires a value in the field then you need to check the
data being sent from the form and if it's empty you need to substitute a
bank "" or a NULL.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

In my "code view" I have a custom SQL (DRW) that updates a
database based on values from the previous page. I have
two asp pages...Page 1 is a form, Page 2 is a DRW with the
code shown below:

s-sql="UPDATE Job_test SET OperativeID='::OperativeID::',
Account_Details_Job_No='::Account_Details_Job_No::'
,
Account_Details_Date_Issued='::Account_Details_Date
_Issued::',
Account_Details_Date_of_Job='::Account_Details_Date
_of_Job::',
Account_Details_Acc_No='::Account_Details_Acc_No::
WHERE JobID=::JobID::"

I keep getting the error message:

----------------------

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver]
Syntax error in UPDATE statement.
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

One or more form fields were empty. You should provide
default values for all form fields that are used in the
query.

-------------------------

Not all the fields on the previuous page as filled in - as
they are non-mandatory.

What can I do to make this work?

skc


.
 
D

David Berry

Here's an example:

If Len(Request.Form("OperativeID") < 0 then
OperativeID = ""
else
OperativeID = Request.Form("OperativeID")
end if

If you do this check for all fields then you can ensure that something is
getting inserted into the database, even if it's a blank. Otherwise you
need to break down your SQL statement to only do the parts where there's
data in the field. Here's an example of what I mean from Beginning ASP
Databases by Wrox. what it does is only include the fields in the SQL
statement where there's a value.

'Declare variables needed
Dim strInsert
Dim strValues
Dim strSQL
Dim adCmdText
Dim blnCriticalError
Dim blnFirstParameter

'Set required variables
adCmdText = 1


'Start building the SQL string
strSQL = "Update Clubs Set"

'Set the first parameter flag to true
blnFirstParameter = True

'Update meeting date if present
If Len(Request.Form("txtMeetingDate")) > 0 Then
'Add the value to the SQL string
strSQL = strSQL & " ClubAnnualMeeting = '" & _
Cstr(Request.Form("txtMeetingDate")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update club dues if present
If Len(Request.Form("txtClubDues")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubDues = "
Else
strSQL = strSQL & ", ClubDues = "
End If
strSQL = strSQL & CCur(Request.Form("txtClubDues"))
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update web site URL if present
If Len(Request.Form("txtWebSite")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubWWWSite = '"
Else
strSQL = strSQL & ", ClubWWWSite = '"
End If
strSQL = strSQL & Cstr(Request.Form("txtWebSite")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update cranes if checked
If Request.Form("chkCrane") = 1 Then
'Add True to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubHasCranes = True"
Else
strSQL = strSQL & ", ClubHasCranes = True"
End If
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update club membership number if present
If Len(Request.Form("txtMembers")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubMembership = "
Else
strSQL = strSQL & ", ClubMembership = "
End If
strSQL = strSQL & CLng(Request.Form("txtMembers"))
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update notes if present
If Len(Request.Form("txtNotes")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubNote = '"
Else
strSQL = strSQL & ", ClubNote = '"
End If
strSQL = strSQL & Cstr(Request.Form("txtNotes")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Set the Where clause
strSQL = strSQL & " Where ClubCode = '" & _
Request.Form("txtClubCode") & "'"

'Create and open the database object
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=Sailors"

'Create the command object
Set objCmd = Server.CreateObject("ADODB.Command")

'Set the command object properties
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText

'Execute the command
objCmd.Execute




--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------

-----------------------------------

skc said:
My database does not reuqire a value as the fields can be
blank.

I do not understand what you mean - can you repeat please.
-----Original Message-----
If your database requires a value in the field then you need to check the
data being sent from the form and if it's empty you need to substitute a
bank "" or a NULL.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

In my "code view" I have a custom SQL (DRW) that updates a
database based on values from the previous page. I have
two asp pages...Page 1 is a form, Page 2 is a DRW with the
code shown below:

s-sql="UPDATE Job_test SET OperativeID='::OperativeID::',
Account_Details_Job_No='::Account_Details_Job_No::'
,
Account_Details_Date_Issued='::Account_Details_Date
_Issued::',
Account_Details_Date_of_Job='::Account_Details_Date
_of_Job::',
Account_Details_Acc_No='::Account_Details_Acc_No::
WHERE JobID=::JobID::"

I keep getting the error message:

----------------------

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver]
Syntax error in UPDATE statement.
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

One or more form fields were empty. You should provide
default values for all form fields that are used in the
query.

-------------------------

Not all the fields on the previuous page as filled in - as
they are non-mandatory.

What can I do to make this work?

skc


.
 
S

skc

Wow...you are frightening me!!

So...what is different between me directly saving the form
to the database (which works and does not matter if the
fields are blank) or using a UPDATE sql in a DRW on
another .asp page?

I want to use the UPDATE, as I do not want a repeated
record in my database table.

I am holding details on Jobs, where the person applying
submits additional details to the already pre-exisitng
record which gives minmum of information. I have a list
(table) of jobs with a hyperlink using a DRW, and once the
job is completed by the applicant I want that record
updated - not another one created - by doing a simple save
to database.

How can I get around this???

skc
-----Original Message-----
Here's an example:

If Len(Request.Form("OperativeID") < 0 then
OperativeID = ""
else
OperativeID = Request.Form("OperativeID")
end if

If you do this check for all fields then you can ensure that something is
getting inserted into the database, even if it's a blank. Otherwise you
need to break down your SQL statement to only do the parts where there's
data in the field. Here's an example of what I mean from Beginning ASP
Databases by Wrox. what it does is only include the fields in the SQL
statement where there's a value.

'Declare variables needed
Dim strInsert
Dim strValues
Dim strSQL
Dim adCmdText
Dim blnCriticalError
Dim blnFirstParameter

'Set required variables
adCmdText = 1


'Start building the SQL string
strSQL = "Update Clubs Set"

'Set the first parameter flag to true
blnFirstParameter = True

'Update meeting date if present
If Len(Request.Form("txtMeetingDate")) > 0 Then
'Add the value to the SQL string
strSQL = strSQL & " ClubAnnualMeeting = '" & _
Cstr(Request.Form("txtMeetingDate")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update club dues if present
If Len(Request.Form("txtClubDues")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubDues = "
Else
strSQL = strSQL & ", ClubDues = "
End If
strSQL = strSQL & CCur(Request.Form("txtClubDues"))
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update web site URL if present
If Len(Request.Form("txtWebSite")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubWWWSite = '"
Else
strSQL = strSQL & ", ClubWWWSite = '"
End If
strSQL = strSQL & Cstr(Request.Form("txtWebSite")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update cranes if checked
If Request.Form("chkCrane") = 1 Then
'Add True to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubHasCranes = True"
Else
strSQL = strSQL & ", ClubHasCranes = True"
End If
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update club membership number if present
If Len(Request.Form("txtMembers")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubMembership = "
Else
strSQL = strSQL & ", ClubMembership = "
End If
strSQL = strSQL & CLng(Request.Form("txtMembers"))
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update notes if present
If Len(Request.Form("txtNotes")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubNote = '"
Else
strSQL = strSQL & ", ClubNote = '"
End If
strSQL = strSQL & Cstr(Request.Form("txtNotes")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Set the Where clause
strSQL = strSQL & " Where ClubCode = '" & _
Request.Form("txtClubCode") & "'"

'Create and open the database object
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=Sailors"

'Create the command object
Set objCmd = Server.CreateObject("ADODB.Command")

'Set the command object properties
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText

'Execute the command
objCmd.Execute




--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

My database does not reuqire a value as the fields can be
blank.

I do not understand what you mean - can you repeat please.
-----Original Message-----
If your database requires a value in the field then you need to check the
data being sent from the form and if it's empty you
need
to substitute a
bank "" or a NULL.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net- sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

In my "code view" I have a custom SQL (DRW) that updates a
database based on values from the previous page. I have
two asp pages...Page 1 is a form, Page 2 is a DRW
with
the
code shown below:

s-sql="UPDATE Job_test SET OperativeID='::OperativeID::',
Account_Details_Job_No='::Account_Details_Job_No::'
,
Account_Details_Date_Issued='::Account_Details_Date
_Issued::',
Account_Details_Date_of_Job='::Account_Details_Date
_of_Job::',
Account_Details_Acc_No='::Account_Details_Acc_No::
WHERE JobID=::JobID::"

I keep getting the error message:

----------------------

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver]
Syntax error in UPDATE statement.
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

One or more form fields were empty. You should provide
default values for all form fields that are used in the
query.
in -
as
they are non-mandatory.

What can I do to make this work?

skc


.


.
 
D

David Berry

When you use the UPDATE statement just add a WHERE clause to make sure the
correct record is updated. As for the difference between using ASP and the
DRW, you have more control when you use ASP. Try these sites for tutorials:

www.asp101.com
www.learnasp.com
www.takempis.com
www.4guysfromrolla.com


--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------

-----------------------------------

skc said:
Wow...you are frightening me!!

So...what is different between me directly saving the form
to the database (which works and does not matter if the
fields are blank) or using a UPDATE sql in a DRW on
another .asp page?

I want to use the UPDATE, as I do not want a repeated
record in my database table.

I am holding details on Jobs, where the person applying
submits additional details to the already pre-exisitng
record which gives minmum of information. I have a list
(table) of jobs with a hyperlink using a DRW, and once the
job is completed by the applicant I want that record
updated - not another one created - by doing a simple save
to database.

How can I get around this???

skc
-----Original Message-----
Here's an example:

If Len(Request.Form("OperativeID") < 0 then
OperativeID = ""
else
OperativeID = Request.Form("OperativeID")
end if

If you do this check for all fields then you can ensure that something is
getting inserted into the database, even if it's a blank. Otherwise you
need to break down your SQL statement to only do the parts where there's
data in the field. Here's an example of what I mean from Beginning ASP
Databases by Wrox. what it does is only include the fields in the SQL
statement where there's a value.

'Declare variables needed
Dim strInsert
Dim strValues
Dim strSQL
Dim adCmdText
Dim blnCriticalError
Dim blnFirstParameter

'Set required variables
adCmdText = 1


'Start building the SQL string
strSQL = "Update Clubs Set"

'Set the first parameter flag to true
blnFirstParameter = True

'Update meeting date if present
If Len(Request.Form("txtMeetingDate")) > 0 Then
'Add the value to the SQL string
strSQL = strSQL & " ClubAnnualMeeting = '" & _
Cstr(Request.Form("txtMeetingDate")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update club dues if present
If Len(Request.Form("txtClubDues")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubDues = "
Else
strSQL = strSQL & ", ClubDues = "
End If
strSQL = strSQL & CCur(Request.Form("txtClubDues"))
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update web site URL if present
If Len(Request.Form("txtWebSite")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubWWWSite = '"
Else
strSQL = strSQL & ", ClubWWWSite = '"
End If
strSQL = strSQL & Cstr(Request.Form("txtWebSite")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update cranes if checked
If Request.Form("chkCrane") = 1 Then
'Add True to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubHasCranes = True"
Else
strSQL = strSQL & ", ClubHasCranes = True"
End If
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update club membership number if present
If Len(Request.Form("txtMembers")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubMembership = "
Else
strSQL = strSQL & ", ClubMembership = "
End If
strSQL = strSQL & CLng(Request.Form("txtMembers"))
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Update notes if present
If Len(Request.Form("txtNotes")) > 0 Then
'Add the value to the SQL string
If blnFirstParameter Then
strSQL = strSQL & " ClubNote = '"
Else
strSQL = strSQL & ", ClubNote = '"
End If
strSQL = strSQL & Cstr(Request.Form("txtNotes")) & "'"
'Set the first parameter flag to false
blnFirstParameter = False
End If

'Set the Where clause
strSQL = strSQL & " Where ClubCode = '" & _
Request.Form("txtClubCode") & "'"

'Create and open the database object
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=Sailors"

'Create the command object
Set objCmd = Server.CreateObject("ADODB.Command")

'Set the command object properties
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strSQL
objCmd.CommandType = adCmdText

'Execute the command
objCmd.Execute




--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net-sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

My database does not reuqire a value as the fields can be
blank.

I do not understand what you mean - can you repeat please.

-----Original Message-----
If your database requires a value in the field then you
need to check the
data being sent from the form and if it's empty you need
to substitute a
bank "" or a NULL.

--
David Berry - MCP
Microsoft MVP - FrontPage
FrontPage Support: http://www.net- sites.com/sitebuilder/
-----------------------------------
To assist you in getting the best answers for FrontPage
support see:
http://www.net-sites.com/sitebuilder/newsgroups.asp
-----------------------------------

message
In my "code view" I have a custom SQL (DRW) that
updates a
database based on values from the previous page. I have
two asp pages...Page 1 is a form, Page 2 is a DRW with
the
code shown below:

s-sql="UPDATE Job_test SET
OperativeID='::OperativeID::',
Account_Details_Job_No='::Account_Details_Job_No::'
,
Account_Details_Date_Issued='::Account_Details_Date
_Issued::',
Account_Details_Date_of_Job='::Account_Details_Date
_of_Job::',
Account_Details_Acc_No='::Account_Details_Acc_No::
WHERE JobID=::JobID::"

I keep getting the error message:

----------------------

Database Results Error
Description: [Microsoft][ODBC Microsoft Access Driver]
Syntax error in UPDATE statement.
Number: -2147217900 (0x80040E14)
Source: Microsoft OLE DB Provider for ODBC Drivers

One or more form fields were empty. You should provide
default values for all form fields that are used in the
query.

-------------------------

Not all the fields on the previuous page as filled in -
as
they are non-mandatory.

What can I do to make this work?

skc


.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DBI update failure 8
Updating Access database 6
Database Interface Wizard 3
SQL Update 3
FrontPage-Data Results 1
editing data with database editor error 2
Zip Code Search 7
Dabase Results Page 14

Top