This topic is locked

SQL Code Error

10/29/2003 10:44:44 AM
ASPRunnerPro General questions
swat author

hi,
I have this two SQL codes that I'd like to be run ,first one just gets the data from my database and the second sql code I plan to resign ID to different value..but getting Error...anyone has came cross with this problem ?
"

gstrSQL =" update [product] SET [ID] = 4 WHERE [ID] = 7 "[/b]
thx

500067 10/30/2003

Swat,

The only way I have been able to get around this is to declare and assign a different name to the second statement. I'll look to see if Admin posts a different solution. Please see my validation post. You had a solution but I couldn't get it to stop giving me Bill Gates error messages.
Thanks,

Bandit

Sergey Kornilov admin 10/30/2003

Swat,
you cannot change values of key columns ( I guess this field is autonumber in MS Access). The idea of key column is that it's assigned when new record is created and never changed.
Best regards,

Sergey Kornilov

swat author 10/30/2003

hi admin,
Let say I want to change [Year] field which is number format , but still the same error, I do not think it is because of the format of [ID] .

gstrSQL = "select [ID], [Month], [Year] From [product] "

gstrSQL =" update [product] SET [Year] = 2002 WHERE [Year] = 2003 "


hi Bandit,

The only way I have been able to get around this is to declare and assign a different name to the second statement. I'll look to see if Admin posts a different solution. Please see my validation post. You had a solution but I couldn't get it to stop giving me Bill Gates error messages.


thanks for advise however this does not work, again the problem is not related to the SQL code set up (I think) it is because of ASPRUNNER format does not let me run more then one SQL code....
thx all

M
MaxLm 11/1/2003

Hello swat-
If your ID is your Primary Key, and it has a related Foreign Key, you will not be able to do this from asp runner's _edit screen. In VB6, you can by making the change to its related foreign keys at the same time. However, if there is no Foreign key associated with this Key, unless the value is not a duplicate, it may work, not sure.
Easiest thing is change your ID to Number and do a "max(Id)+1" on your code if its a key.
hope it helps.

Sergey Kornilov admin 11/2/2003

Swat,
could you post here table structure (list of columns, column types, key column), SQL code that you execute and exact error message here?
Just in case here is how you need to run SQL update statements in ASP code:

dbConnection.Execute "update [product] SET [Year] = 2002 WHERE [Year] = 2003"


Best regards,

Sergey Kornilov

swat author 11/3/2003

Admin,
Table format:
ID (auto) key column

Name (text)

LastName (text)

Product (text)

Month (text)

Year (text)

Price (number)
Sql code:
dbConnection.Execute "update [product] SET [Year] = '2002' WHERE [Year] = '2003' "
Error Type:

Microsoft VBScript runtime (0x800A01A8)

Object required: 'dbConnection'

/test/calendar/product_list3.asp, line 23

Sergey Kornilov admin 11/4/2003

Hi,
everything looks great except you need to put this line of code after dbConnection object is created.
Best regards,

Sergey Kornilov

swat author 11/4/2003

admin-
I have coded after dbConnection but still error
Microsoft VBScript runtime (0x800A01A8)

Object required: ""

/test/calendar/product_list3.asp, line 35

Sergey Kornilov admin 11/5/2003

Swat,
post portion of product_list3.asp file here that includes dbConnection creation and dbConnection.Execute statement and specify where where line 35 is.
Best regards,

Sergey Kornilov

swat author 11/6/2003

here is the my code it works just fine ,however when add the second sql code:

gives me error.
<%@ Language=VBScript %>
<%

If Session("UserID")="" Then

Response.Redirect "product_login.asp"

End If

%>
<%

strKeyField="ID"

strKeyField2=""

strKeyField3=""

strTableName="[product]"

PageSize=100

strLeftWrapper="["

strRightWrapper="]"

strOrderBy=""

bKeyFieldEditable1=True

bKeyFieldEditable2=False

bKeyFieldEditable3=False

[color=red]gstrSQL= select "[ID],[Name],[LastName],[Product],[Month],[Year],[Price] From [product] "

debug = false
Const FORMAT_NONE = ""

Const FORMAT_DATE_SHORT = "Short Date"

Const FORMAT_DATE_LONG = "Long Date"

Const FORMAT_DATE_TIME = "Time"

Const FORMAT_CURRENCY = "Currency"

Const FORMAT_HYPERLINK = "Hypelink"

Const FORMAT_EMAILHYPERLINK = "Email Hyperlink"

Const FORMAT_FILE_IMAGE = "File-based image"

Const FORMAT_LOOKUP_WIZARD = "Lookup wizard"
Const EDIT_DATE_SIMPLE = 0

Const EDIT_DATE_SIMPLE_DDMMYYYY_DP = 1

Const EDIT_DATE_SIMPLE_MMDDYYYY_DP = 2

Const EDIT_DATE_DDMMYYYY = 3

Const EDIT_DATE_DDMMYYYY_DP = 4

Const EDIT_DATE_MMDDYYYY = 5

Const EDIT_DATE_MMDDYYYY_DP = 6
Const LOGIN_HARDCODED = 0

Const LOGIN_TABLE = 1

cLoginMethod = 1

cUserName = ""

cPassword = ""

cLoginTable = "User"

cUserNameField = "User Name"

cPasswordField = "User Pass"

%>
<link REL="stylesheet" href="include/style.css" type="text/css">

<!--#include file="include/dbconnection.asp"-->

<!--#include file="include/product_aspfunctions.asp"-->

<%
On Error Resume Next
strOrderImage=""

Call CalculateOrderBy

Sergey Kornilov admin 11/7/2003

Swat,
this line need to be inserted after dbConnection object is created.

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

Call ReportError
dbConnection.Execute "update [product] SET [Year] = '2002' WHERE [Year] = '2003' "


Best regards,

Sergey Kornilov

swat author 11/10/2003

admin-
the code works just fine..Thank you <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=735&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />
swat <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=735&image=2&table=forumreplies' class='bbc_emoticon' alt=':D' />

swat author 12/11/2003

hi admin,

set dbConnection = server.CreateObject ("ADODB.Connection")

dbConnection.ConnectionString = strConnection

dbConnection.Open

Call ReportError
dbConnection.Execute "update [product] SET [Year] = '2002' WHERE [Year] = '2003' "


If you remember ,this sql statament used to work on last version of ASPRUNNER . However now I am trying to use same sql code but seems to me not working . Is it new version configuration or me?
Thank you <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=805&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />

Sergey Kornilov admin 12/11/2003

Swat,
try to execute this statement in MS Access to see what's wrong.

update [product] SET [Year] = '2002' WHERE [Year] = '2003'


Best regards,

Sergey Kornilov

swat author 12/11/2003

Swat,

try to execute this statement in MS Access to see what's wrong.

update [product] SET [Year] = '2002' WHERE [Year] = '2003'


Best regards,

Sergey Kornilov



hi admin-
The SQL code works just fine with MS Access Query, but not in asprunner.

Note: I have set up The [Year] data field as TEXT

thank you

Sergey Kornilov admin 12/11/2003

Swat,
what error message do you get?
Best regards,

Sergey Kornilov

swat author 12/11/2003

admin-
The asp page does not give me any error messages... I have plug this code inside of the product_list page so when user hits page SQL code must be running in the backround. But I can see the product_list page displayed fine but the sql did not go through.
thx

Sergey Kornilov admin 12/11/2003

Swat,
probably this code is not executed.
Try to comment On Error Resume Next line to make sure it works without errors.
Best regards,

Sergey Kornilov