err object

L

led

i have this code:

<%
Dim myConnString
Dim myConnection
Dim mySQL


myConnString = Application("basededados1_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")


myConnection.Open myConnString

mySQL= "INSERT INTO casas"
mySQL= mySQL &
"(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
"
mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
mySQL= mySQL & request("designacao")
mySQL= mySQL & "','" & request("tipo")
mySQL= mySQL & "','" & request("piscina")
mySQL= mySQL & "','" & request("grelhador")
mySQL= mySQL & "','" & request("roupas")
mySQL= mySQL & "','" & request("televisao")
mySQL= mySQL & "','" & request("ar_condicionado")
mySQL= mySQL & "','" & request("localidade")
mySQL= mySQL & "','" & request("dist_praia")
mySQL= mySQL & "','" & request("pessoas")
mySQL= mySQL & "','" & request("sess") & "')"

response.write(mysql)


myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

%>

it was nice when a error occurs ,ex: index duplicates ,a custom message .
this is the error:
Microsoft JET Database Engine error '80004005'

The changes you requested to the table were not successful because they
would create duplicate values in the index, primary key, or relationship.
Change the data in the field or fields that contain duplicate data, remove
the index, or redefine the index to permit duplicate entries and try again.
 
S

Stefan B Rusynko

The Error is clearly telling you what is wrong
- you are trying to write a record w/ data that would violate your DB structure
(by creating duplicate values in the index, primary key, or a relationship)
- check your data or DB structure for the field that is causing the duplication or violation
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|i have this code:
|
| <%
| Dim myConnString
| Dim myConnection
| Dim mySQL
|
|
| myConnString = Application("basededados1_ConnectionString")
| Set myConnection = Server.CreateObject("ADODB.Connection")
|
|
| myConnection.Open myConnString
|
| mySQL= "INSERT INTO casas"
| mySQL= mySQL &
| "(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
| "
| mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
| mySQL= mySQL & request("designacao")
| mySQL= mySQL & "','" & request("tipo")
| mySQL= mySQL & "','" & request("piscina")
| mySQL= mySQL & "','" & request("grelhador")
| mySQL= mySQL & "','" & request("roupas")
| mySQL= mySQL & "','" & request("televisao")
| mySQL= mySQL & "','" & request("ar_condicionado")
| mySQL= mySQL & "','" & request("localidade")
| mySQL= mySQL & "','" & request("dist_praia")
| mySQL= mySQL & "','" & request("pessoas")
| mySQL= mySQL & "','" & request("sess") & "')"
|
| response.write(mysql)
|
|
| myConnection.Execute mySQL
| myConnection.Close
| Set myConnection = Nothing
|
| %>
|
| it was nice when a error occurs ,ex: index duplicates ,a custom message .
| this is the error:
| Microsoft JET Database Engine error '80004005'
|
| The changes you requested to the table were not successful because they
| would create duplicate values in the index, primary key, or relationship.
| Change the data in the field or fields that contain duplicate data, remove
| the index, or redefine the index to permit duplicate entries and try again.
|
|
 
D

David Berry

Change your code to this:

On Error Resume Next
myConnection.Execute mySQL
If Err.description <> "" Then
Response.Write "<H1>Database Query Error: " & Err.description &
"</H1>"
End If
myConnection.Close
Set myConnection = Nothing

If you want a different custom message then just change the Response.Write
line. Ex:

Response.Write "You Can't Do That"

See http://support.microsoft.com/kb/300043 for more information on error
handling.


led said:
but i want to generate a custom message if this error hapens
Stefan B Rusynko said:
The Error is clearly telling you what is wrong
- you are trying to write a record w/ data that would violate your DB
structure
(by creating duplicate values in the index, primary key, or a
relationship)
- check your data or DB structure for the field that is causing the
duplication or violation
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|i have this code:
|
| <%
| Dim myConnString
| Dim myConnection
| Dim mySQL
|
|
| myConnString = Application("basededados1_ConnectionString")
| Set myConnection = Server.CreateObject("ADODB.Connection")
|
|
| myConnection.Open myConnString
|
| mySQL= "INSERT INTO casas"
| mySQL= mySQL &
|
"(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
| "
| mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
| mySQL= mySQL & request("designacao")
| mySQL= mySQL & "','" & request("tipo")
| mySQL= mySQL & "','" & request("piscina")
| mySQL= mySQL & "','" & request("grelhador")
| mySQL= mySQL & "','" & request("roupas")
| mySQL= mySQL & "','" & request("televisao")
| mySQL= mySQL & "','" & request("ar_condicionado")
| mySQL= mySQL & "','" & request("localidade")
| mySQL= mySQL & "','" & request("dist_praia")
| mySQL= mySQL & "','" & request("pessoas")
| mySQL= mySQL & "','" & request("sess") & "')"
|
| response.write(mysql)
|
|
| myConnection.Execute mySQL
| myConnection.Close
| Set myConnection = Nothing
|
| %>
|
| it was nice when a error occurs ,ex: index duplicates ,a custom message
.
| this is the error:
| Microsoft JET Database Engine error '80004005'
|
| The changes you requested to the table were not successful because they
| would create duplicate values in the index, primary key, or
relationship.
| Change the data in the field or fields that contain duplicate data,
remove
| the index, or redefine the index to permit duplicate entries and try
again.
|
|
 
M

Murray

I prefer -

Response.Write "Bad coder, Bad, Bad!"

--
Murray
--------------
MVP FrontPage


David Berry said:
Change your code to this:

On Error Resume Next
myConnection.Execute mySQL
If Err.description <> "" Then
Response.Write "<H1>Database Query Error: " & Err.description &
"</H1>"
End If
myConnection.Close
Set myConnection = Nothing

If you want a different custom message then just change the Response.Write
line. Ex:

Response.Write "You Can't Do That"

See http://support.microsoft.com/kb/300043 for more information on error
handling.


led said:
but i want to generate a custom message if this error hapens
Stefan B Rusynko said:
The Error is clearly telling you what is wrong
- you are trying to write a record w/ data that would violate your DB
structure
(by creating duplicate values in the index, primary key, or a
relationship)
- check your data or DB structure for the field that is causing the
duplication or violation
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|i have this code:
|
| <%
| Dim myConnString
| Dim myConnection
| Dim mySQL
|
|
| myConnString = Application("basededados1_ConnectionString")
| Set myConnection = Server.CreateObject("ADODB.Connection")
|
|
| myConnection.Open myConnString
|
| mySQL= "INSERT INTO casas"
| mySQL= mySQL &
|
"(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
| "
| mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
| mySQL= mySQL & request("designacao")
| mySQL= mySQL & "','" & request("tipo")
| mySQL= mySQL & "','" & request("piscina")
| mySQL= mySQL & "','" & request("grelhador")
| mySQL= mySQL & "','" & request("roupas")
| mySQL= mySQL & "','" & request("televisao")
| mySQL= mySQL & "','" & request("ar_condicionado")
| mySQL= mySQL & "','" & request("localidade")
| mySQL= mySQL & "','" & request("dist_praia")
| mySQL= mySQL & "','" & request("pessoas")
| mySQL= mySQL & "','" & request("sess") & "')"
|
| response.write(mysql)
|
|
| myConnection.Execute mySQL
| myConnection.Close
| Set myConnection = Nothing
|
| %>
|
| it was nice when a error occurs ,ex: index duplicates ,a custom
message .
| this is the error:
| Microsoft JET Database Engine error '80004005'
|
| The changes you requested to the table were not successful because
they
| would create duplicate values in the index, primary key, or
relationship.
| Change the data in the field or fields that contain duplicate data,
remove
| the index, or redefine the index to permit duplicate entries and try
again.
|
|
 
D

David Berry

LOL!

Yes. If the insert is going to create a duplicate record then it should be
re-coded or the database redesigned.


Murray said:
I prefer -

Response.Write "Bad coder, Bad, Bad!"

--
Murray
--------------
MVP FrontPage


David Berry said:
Change your code to this:

On Error Resume Next
myConnection.Execute mySQL
If Err.description <> "" Then
Response.Write "<H1>Database Query Error: " & Err.description &
"</H1>"
End If
myConnection.Close
Set myConnection = Nothing

If you want a different custom message then just change the
Response.Write line. Ex:

Response.Write "You Can't Do That"

See http://support.microsoft.com/kb/300043 for more information on error
handling.


led said:
but i want to generate a custom message if this error hapens
"Stefan B Rusynko" <[email protected]> escreveu na mensagem
The Error is clearly telling you what is wrong
- you are trying to write a record w/ data that would violate your DB
structure
(by creating duplicate values in the index, primary key, or a
relationship)
- check your data or DB structure for the field that is causing the
duplication or violation
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|i have this code:
|
| <%
| Dim myConnString
| Dim myConnection
| Dim mySQL
|
|
| myConnString = Application("basededados1_ConnectionString")
| Set myConnection = Server.CreateObject("ADODB.Connection")
|
|
| myConnection.Open myConnString
|
| mySQL= "INSERT INTO casas"
| mySQL= mySQL &
|
"(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
| "
| mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
| mySQL= mySQL & request("designacao")
| mySQL= mySQL & "','" & request("tipo")
| mySQL= mySQL & "','" & request("piscina")
| mySQL= mySQL & "','" & request("grelhador")
| mySQL= mySQL & "','" & request("roupas")
| mySQL= mySQL & "','" & request("televisao")
| mySQL= mySQL & "','" & request("ar_condicionado")
| mySQL= mySQL & "','" & request("localidade")
| mySQL= mySQL & "','" & request("dist_praia")
| mySQL= mySQL & "','" & request("pessoas")
| mySQL= mySQL & "','" & request("sess") & "')"
|
| response.write(mysql)
|
|
| myConnection.Execute mySQL
| myConnection.Close
| Set myConnection = Nothing
|
| %>
|
| it was nice when a error occurs ,ex: index duplicates ,a custom
message .
| this is the error:
| Microsoft JET Database Engine error '80004005'
|
| The changes you requested to the table were not successful because
they
| would create duplicate values in the index, primary key, or
relationship.
| Change the data in the field or fields that contain duplicate data,
remove
| the index, or redefine the index to permit duplicate entries and try
again.
|
|
 
L

led

the problem is when the user refresh the page. thats what im trying to do
writing the session id in a field.
David Berry said:
LOL!

Yes. If the insert is going to create a duplicate record then it should
be re-coded or the database redesigned.


Murray said:
I prefer -

Response.Write "Bad coder, Bad, Bad!"

--
Murray
--------------
MVP FrontPage


David Berry said:
Change your code to this:

On Error Resume Next
myConnection.Execute mySQL
If Err.description <> "" Then
Response.Write "<H1>Database Query Error: " & Err.description
& "</H1>"
End If
myConnection.Close
Set myConnection = Nothing

If you want a different custom message then just change the
Response.Write line. Ex:

Response.Write "You Can't Do That"

See http://support.microsoft.com/kb/300043 for more information on error
handling.


but i want to generate a custom message if this error hapens
"Stefan B Rusynko" <[email protected]> escreveu na mensagem
The Error is clearly telling you what is wrong
- you are trying to write a record w/ data that would violate your DB
structure
(by creating duplicate values in the index, primary key, or a
relationship)
- check your data or DB structure for the field that is causing the
duplication or violation
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:

http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|i have this code:
|
| <%
| Dim myConnString
| Dim myConnection
| Dim mySQL
|
|
| myConnString = Application("basededados1_ConnectionString")
| Set myConnection = Server.CreateObject("ADODB.Connection")
|
|
| myConnection.Open myConnString
|
| mySQL= "INSERT INTO casas"
| mySQL= mySQL &
|
"(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
| "
| mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
| mySQL= mySQL & request("designacao")
| mySQL= mySQL & "','" & request("tipo")
| mySQL= mySQL & "','" & request("piscina")
| mySQL= mySQL & "','" & request("grelhador")
| mySQL= mySQL & "','" & request("roupas")
| mySQL= mySQL & "','" & request("televisao")
| mySQL= mySQL & "','" & request("ar_condicionado")
| mySQL= mySQL & "','" & request("localidade")
| mySQL= mySQL & "','" & request("dist_praia")
| mySQL= mySQL & "','" & request("pessoas")
| mySQL= mySQL & "','" & request("sess") & "')"
|
| response.write(mysql)
|
|
| myConnection.Execute mySQL
| myConnection.Close
| Set myConnection = Nothing
|
| %>
|
| it was nice when a error occurs ,ex: index duplicates ,a custom
message .
| this is the error:
| Microsoft JET Database Engine error '80004005'
|
| The changes you requested to the table were not successful because
they
| would create duplicate values in the index, primary key, or
relationship.
| Change the data in the field or fields that contain duplicate data,
remove
| the index, or redefine the index to permit duplicate entries and try
again.
|
|
 
D

David Berry

Ah yes. Those pesky users. In that case after the Insert is complete I
would do a Response.Redirect and send them off to another page that says
something like "Your record has been added to the database". Ex:

Response.Redirect ("Thanks.asp)

That way they're off that page and if they hit refresh it won't try and
insert a new record. If you're using Sessions then when you direct them to
the next page clear out the session variable so that even if they try and go
back it won't be there. You could also do a quick check in the database to
see if that record ID exists before the insert happens. There are a number
of things you could do to make sure that they don't enter duplicates.




led said:
the problem is when the user refresh the page. thats what im trying to do
writing the session id in a field.
David Berry said:
LOL!

Yes. If the insert is going to create a duplicate record then it should
be re-coded or the database redesigned.


Murray said:
I prefer -

Response.Write "Bad coder, Bad, Bad!"

--
Murray
--------------
MVP FrontPage


Change your code to this:

On Error Resume Next
myConnection.Execute mySQL
If Err.description <> "" Then
Response.Write "<H1>Database Query Error: " & Err.description
& "</H1>"
End If
myConnection.Close
Set myConnection = Nothing

If you want a different custom message then just change the
Response.Write line. Ex:

Response.Write "You Can't Do That"

See http://support.microsoft.com/kb/300043 for more information on
error handling.


but i want to generate a custom message if this error hapens
"Stefan B Rusynko" <[email protected]> escreveu na mensagem
The Error is clearly telling you what is wrong
- you are trying to write a record w/ data that would violate your DB
structure
(by creating duplicate values in the index, primary key, or a
relationship)
- check your data or DB structure for the field that is causing the
duplication or violation
--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:

http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


|i have this code:
|
| <%
| Dim myConnString
| Dim myConnection
| Dim mySQL
|
|
| myConnString = Application("basededados1_ConnectionString")
| Set myConnection = Server.CreateObject("ADODB.Connection")
|
|
| myConnection.Open myConnString
|
| mySQL= "INSERT INTO casas"
| mySQL= mySQL &
|
"(proprietario,[designação],tipo,piscina,grelhador,roupas,[televisão],ar_condicionado,localidade,dist_praia,pessoas,sessid)
| "
| mySQL= mySQL & "VALUES ('" & request("proprietario") & "','"
| mySQL= mySQL & request("designacao")
| mySQL= mySQL & "','" & request("tipo")
| mySQL= mySQL & "','" & request("piscina")
| mySQL= mySQL & "','" & request("grelhador")
| mySQL= mySQL & "','" & request("roupas")
| mySQL= mySQL & "','" & request("televisao")
| mySQL= mySQL & "','" & request("ar_condicionado")
| mySQL= mySQL & "','" & request("localidade")
| mySQL= mySQL & "','" & request("dist_praia")
| mySQL= mySQL & "','" & request("pessoas")
| mySQL= mySQL & "','" & request("sess") & "')"
|
| response.write(mysql)
|
|
| myConnection.Execute mySQL
| myConnection.Close
| Set myConnection = Nothing
|
| %>
|
| it was nice when a error occurs ,ex: index duplicates ,a custom
message .
| this is the error:
| Microsoft JET Database Engine error '80004005'
|
| The changes you requested to the table were not successful because
they
| would create duplicate values in the index, primary key, or
relationship.
| Change the data in the field or fields that contain duplicate data,
remove
| the index, or redefine the index to permit duplicate entries and
try again.
|
|
 

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

rewriting with refresh 1

Top