Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

hudsonalves

Erro: Microsoft OLE DB Provider for ODBC Drivers erro '80040e14&#3

Recommended Posts

Galera, estou tendo problema para incluir um formulário com envio de foto usando script Pure ASP File e BD access, bem o que acontece: percebi que as imagens são enviadas normalmente para a pasta que estão na rede são redimensionadas de acordo com a configuração do script mas não é gravado no banco de dados e gera o erro:

Microsoft OLE DB Provider for ODBC Drivers erro '80040e14'

[Microsoft][Driver ODBC para Microsoft Access] As alterações solicitadas para a tabela não foram satisfatórias já que criariam valores duplicados no índice, chave primária ou relação. Altere os dados no campo ou campos que contêm os dados duplicados, remova o índice ou redefina o índice para possibilitar entradas duplicadas e tente novamente.

D:\WEB\LOCALUSER\LOJAWEB\WWW\HOME\../includes/inc_register.asp, line 230

A linha em questão é essa:

MM_dbValues = MM_dbValues & MM_formVal

O código java completo é este:

<%
'*** Pure ASP File Upload 2.1.3
Dim GP_uploadAction,UploadQueryString
PureUploadSetup
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim pau_thePath,pau_Extensions,pau_Form,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout,pau_progressBar,pau_progressWidth,pau_progressHeight
  pau_thePath = """../userpictures"""
  pau_Extensions = "GIF,JPG,JPEG,BMP,PNG"
  pau_Form = "register"
  pau_Redirect = ""
  pau_storeType = "file"
  pau_sizeLimit = ""
  pau_nameConflict = "uniq"
  pau_requireUpload = "false"
  pau_minWidth = ""
  pau_minHeight = "" 
  pau_maxWidth = ""
  pau_maxHeight = ""
  pau_saveWidth = ""
  pau_saveHeight = ""
  pau_timeout = "600"
  pau_progressBar = ""
  pau_progressWidth = "300"
  pau_progressHeight = "100"
  
  Dim RequestBin, UploadRequest
  CheckPureUploadVersion 2.13
  ProcessUpload pau_thePath,pau_Extensions,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout
end if
%>
<%
' *** Smart Image Processor 1.1.2
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim RUF_Component, RUF_DotNetResize, RUF_ResizeImages, RUF_AspectImages, RUF_maxWidth, RUF_maxHeight, RUF_Quality, RUF_MakeThumb, RUF_AspectThumb, RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb, RUF_RedirectURL
  RUF_Component = "AUTO"
  RUF_DotNetResize = "../ScriptLibrary/ResizeImage.aspx"
  RUF_ResizeImages = true
  RUF_AspectImages = true
  RUF_maxWidth = "400"
  RUF_maxHeight = "400"  
  RUF_Quality = "80"
  RUF_MakeThumb = true
  RUF_AspectThumb = true
  RUF_Suffix = "_small"
  RUF_maxWidthThumb = "130"
  RUF_maxHeightThumb = "130"
  RUF_QualityThumb = "70"
  RUF_RedirectURL = ""
  if RUF_ResizeImages then
    ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath, "", RUF_maxWidth, RUF_maxHeight, RUF_Quality, true, pau_saveWidth, pau_saveHeight, RUF_AspectImages, pau_nameConflict, ""
  end if
  if RUF_MakeThumb then
    ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath, RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb, false, pau_saveWidth, pau_saveHeight, RUF_AspectThumb, pau_nameConflict, ""
  end if
  if RUF_RedirectURL <> "" then
    Response.Redirect RUF_RedirectURL
  end if
end if
%>

<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Request.QueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  MM_dupKeyRedirect="../home/register.asp"
  MM_rsKeyConnection=MM_connDUportal_STRING
  MM_dupKeyUsernameValue = CStr(Request.Form("EMAIL"))
  MM_dupKeySQL="SELECT EMAIL FROM USERS WHERE EMAIL='" & MM_dupKeyUsernameValue & "'"
  MM_adodbRecordset="ADODB.Recordset"
  set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
  MM_rsKey.ActiveConnection=MM_rsKeyConnection
  MM_rsKey.Source=MM_dupKeySQL
  MM_rsKey.CursorType=0
  MM_rsKey.CursorLocation=2
  MM_rsKey.LockType=3
  MM_rsKey.Open
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "reqemail=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  MM_dupKeyRedirect="../home/register.asp"
  MM_rsKeyConnection=MM_connDUportal_STRING
  MM_dupKeyUsernameValue = CStr(Request.Form("USUARIO"))
  MM_dupKeySQL="SELECT USUARIO FROM USERS WHERE USUARIO='" & MM_dupKeyUsernameValue & "'"
  MM_adodbRecordset="ADODB.Recordset"
  set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
  MM_rsKey.ActiveConnection=MM_rsKeyConnection
  MM_rsKey.Source=MM_dupKeySQL
  MM_rsKey.CursorType=0
  MM_rsKey.CursorLocation=2
  MM_rsKey.LockType=3
  MM_rsKey.Open
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>
<%
' *** Insert Record: set variables

If (CStr(Request("MM_insert")) = "register") Then

  MM_editConnection = MM_connDUportal_STRING
  MM_editTable = "USERS"
  MM_editRedirectUrl = "../home/"
  MM_fieldsStr  = "USUARIO|value|SENHA|value|NOME|value|SOBRENOME|value|EMAIL|value|CPF|value|USERPICTURE|value|ESTADO|value|U_DATED|value"
  MM_columnsStr = "USUARIO|',none,''|SENHA|',none,''|NOME|',none,''|SOBRENOME|',none,''|EMAIL|',none,''|CPF|',none,''|USER_PICTURE|',none,''|ESTADO|',none,''|U_DATED|',none,NULL"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If

End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ", U_ACCESS) values (" & MM_dbValues & ", 'USER')"

  If (Not MM_abortEdit) Then
    ' execute the insert
	
	Session("MM_Username") = Request.Form("USUARIO")
	Response.Cookies("DUportalUser") = Request.Form("USUARIO")
	Response.Cookies("DUportalUser").Expires = Date + 30	
	
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Verifique a ortografia. pode ser um nome de coluna Invalido 'sua_coluna'. A coluna a qual você se refere na Base de Dados não foi encontrada. e também veja se os tipos de dados estão corretos

Compartilhar este post


Link para o post
Compartilhar em outros sites

Alarme falso, aparentemente funcionou para incluir um novo usuário mas voltou dar o mesmo erro, quando tento incluir o mesmo usuário, corrigi esta linha que aparentemente estava errada:

  MM_fieldsStr  = "USUARIO|value|SENHA|value|NOME|value|SOBRENOME|value|EMAIL|value|CPF|value|USER_PICTURE|value|ESTADO|value|U_DATED|value"
  MM_columnsStr = "USUARIO|',none,''|SENHA|',none,''|NOME|',none,''|SOBRENOME|',none,''|EMAIL|',none,''|CPF|',none,''|USER_PICTURE|',none,''|ESTADO|',none,''|U_DATED|',none,NULL"

a minha tabela chama-se: USERS, dentro tenho as colunas: USUARIO, SENHA, U_ACCESS, NOME, SOBRENOME, EMAIL, U_DATED, CPF, ESTADO, USER_PICTURE, USER_HEIGHT, USER_WIDTH

 

 

 

 

 

o código para checar duplicidade é este onde verifico usuário e e-mail se estão em duplicidade:

<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  MM_dupKeyRedirect="../home/register.asp"
  MM_rsKeyConnection=MM_connDUportal_STRING
  MM_dupKeyUsernameValue = CStr(Request.Form("EMAIL"))
  MM_dupKeySQL="SELECT EMAIL FROM USERS WHERE EMAIL='" & MM_dupKeyUsernameValue & "'"
  MM_adodbRecordset="ADODB.Recordset"
  set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
  MM_rsKey.ActiveConnection=MM_rsKeyConnection
  MM_rsKey.Source=MM_dupKeySQL
  MM_rsKey.CursorType=0
  MM_rsKey.CursorLocation=2
  MM_rsKey.LockType=3
  MM_rsKey.Open
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "reqemail=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  MM_dupKeyRedirect="../home/register.asp"
  MM_rsKeyConnection=MM_connDUportal_STRING
  MM_dupKeyUsernameValue = CStr(Request.Form("USUARIO"))
  MM_dupKeySQL="SELECT USUARIO FROM USERS WHERE USUARIO='" & MM_dupKeyUsernameValue & "'"
  MM_adodbRecordset="ADODB.Recordset"
  set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
  MM_rsKey.ActiveConnection=MM_rsKeyConnection
  MM_rsKey.Source=MM_dupKeySQL
  MM_rsKey.CursorType=0
  MM_rsKey.CursorLocation=2
  MM_rsKey.LockType=3
  MM_rsKey.Open
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>

Caso apresente duplicidade o formulário deveria apresentar a orientação:

<% If Request.QueryString("requsername") <> "" Then %>
(Ops!: Nosso sistema identificou que ja existe um usuário com este nome,<a id="fontemenu" href="../home/password.asp">se for o dono deste usuário, basta clicar aqui e reenviar a senha.</a>)
<% End If %>
<% If Request.QueryString("reqemail") <> "" Then %>
(Ops!: Nosso sistema identificou que este e-mail já possui cadastro no site,<a id="fontemenu"href="../home/password.asp">para recuperar sua senha é fácil: basta clicar aqui.</a>)
<% End If %>

Aparentemente esta tudo correto e continua dando erro

Compartilhar este post


Link para o post
Compartilhar em outros sites

dá um response.weite na sua string SQL para ver o que esta sendo passado, certifique-se de que os o tipo dos campos estão corretos e os nomes

Compartilhar este post


Link para o post
Compartilhar em outros sites

Esta tudo ok com os campos, o único problema agora é se eu tentar gravar o mesmo usuário, ao invés da mensagem de duplicidade e/ou infomação que ja existe um usuário com este mesmo nome ele da o erro:

Microsoft OLE DB Provider for ODBC Drivers erro '80040e14'

[Microsoft][Driver ODBC para Microsoft Access] As alterações solicitadas para a tabela não foram satisfatórias já que criariam valores duplicados no índice, chave primária ou relação. Altere os dados no campo ou campos que contêm os dados duplicados, remova o índice ou redefina o índice para possibilitar entradas duplicadas e tente novamente.

D:\WEB\LOCALUSER\LOJAWEB\WWW\HOME\../includes/inc_register.asp, line 230

PAra a inclusão de uma nome que não existe esta normal, incluindo o redimensionamento da imagem

 

 

 

 

 

 

Pelo que entendi o problema esta aqui mas não estou conseguindo resolver, este é o script da linha 230 cujo apontamento do erro é esse: MM_editCmd.Execute

<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(UploadFormRequest("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ", U_ACCESS) values (" & MM_dbValues & ", 'USER')"

  If (Not MM_abortEdit) Then
    ' execute the insert
    
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

provavelmente ele deve estar com chave primária, mas um SELECT antes para ver se existe os dados se tiver dá mensagem de erro senão faz o INSERT

Compartilhar este post


Link para o post
Compartilhar em outros sites

Nada, reorganizei e inclui uma variável que faltava:

<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  MM_dupKeyRedirect="../home/register.asp"
  MM_rsKeyConnection=MM_connDUportal_STRING
  MM_dupKeyUsernameValue = CStr(Request.Form("EMAIL"))
  MM_dupKeySQL="SELECT EMAIL FROM USERS WHERE EMAIL='" & MM_dupKeyUsernameValue & "'"
  MM_adodbRecordset="ADODB.Recordset"
  set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
  MM_rsKey.ActiveConnection=MM_rsKeyConnection
  MM_rsKey.Source=MM_dupKeySQL
  MM_rsKey.CursorType=0
  MM_rsKey.CursorLocation=2
  MM_rsKey.LockType=3
  MM_rsKey.Open
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "reqemail=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>
<%
' *** Redirect if username exists
MM_flag="MM_insert"
If (CStr(Request(MM_flag)) <> "") Then
  MM_dupKeyRedirect="../home/register.asp"
  MM_rsKeyConnection=MM_connDUportal_STRING
  MM_dupKeyUsernameValue = CStr(Request.Form("USUARIO"))
  MM_dupKeySQL="SELECT USUARIO FROM USERS WHERE USUARIO='" & MM_dupKeyUsernameValue & "'"
  MM_adodbRecordset="ADODB.Recordset"
  set MM_rsKey=Server.CreateObject(MM_adodbRecordset)
  MM_rsKey.ActiveConnection=MM_rsKeyConnection
  MM_rsKey.Source=MM_dupKeySQL
  MM_rsKey.CursorType=0
  MM_rsKey.CursorLocation=2
  MM_rsKey.LockType=3
  MM_rsKey.Open
  If Not MM_rsKey.EOF Or Not MM_rsKey.BOF Then 
    ' the username was found - can not add the requested username
    MM_qsChar = "?"
    If (InStr(1,MM_dupKeyRedirect,"?") >= 1) Then MM_qsChar = "&"
    MM_dupKeyRedirect = MM_dupKeyRedirect & MM_qsChar & "requsername=" & MM_dupKeyUsernameValue
    Response.Redirect(MM_dupKeyRedirect)
  End If
  MM_rsKey.Close
End If
%>
<%
'*** Pure ASP File Upload 2.1.7
Dim GP_uploadAction,UploadQueryString
PureUploadSetup
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim pau_thePath,pau_Extensions,pau_Form,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout,pau_progressBar,pau_progressWidth,pau_progressHeight
  pau_thePath = """../userpictures"""
  pau_Extensions = "GIF,JPG,JPEG,BMP,PNG"
  pau_Form = "register"
  pau_Redirect = ""
  pau_storeType = "file"
  pau_sizeLimit = ""
  pau_nameConflict = "uniq"
  pau_requireUpload = "true"
  pau_minWidth = ""
  pau_minHeight = "" 
  pau_maxWidth = ""
  pau_maxHeight = ""
  pau_saveWidth = "USER_WIDTH"
  pau_saveHeight = "USER_HEIGHT"
  pau_timeout = "600"
  pau_progressBar = ""
  pau_progressWidth = "100"
  pau_progressHeight = "100"
  
  Dim RequestBin, UploadRequest
  CheckPureUploadVersion 2.17
  ProcessUpload pau_thePath,pau_Extensions,pau_Redirect,pau_storeType,pau_sizeLimit,pau_nameConflict,pau_requireUpload,pau_minWidth,pau_minHeight,pau_maxWidth,pau_maxHeight,pau_saveWidth,pau_saveHeight,pau_timeout
end if
%>
<%
' *** Smart Image Processor 1.1.2
If (CStr(Request.QueryString("GP_upload")) <> "") Then
  Dim RUF_Component, RUF_DotNetResize, RUF_ResizeImages, RUF_AspectImages, RUF_maxWidth, RUF_maxHeight, RUF_Quality, RUF_MakeThumb, RUF_AspectThumb, RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb, RUF_RedirectURL
  RUF_Component = "AUTO"
  RUF_DotNetResize = "../ScriptLibrary/ResizeImageimage.aspx"
  RUF_ResizeImages = false
  RUF_AspectImages = true
  RUF_maxWidth = "100"
  RUF_maxHeight = "100"  
  RUF_Quality = "100"
  RUF_MakeThumb = true
  RUF_AspectThumb = true
  RUF_Suffix = "_small"
  RUF_maxWidthThumb = "100"
  RUF_maxHeightThumb = "100"
  RUF_QualityThumb = "100"
  RUF_RedirectURL = ""
  if RUF_ResizeImages then
    ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath, "", RUF_maxWidth, RUF_maxHeight, RUF_Quality, true, pau_saveWidth, pau_saveHeight, RUF_AspectImages, pau_nameConflict, ""
  end if
  if RUF_MakeThumb then
    ResizeUploadedFiles RUF_Component, RUF_DotNetResize, pau_thePath, RUF_Suffix, RUF_maxWidthThumb, RUF_maxHeightThumb, RUF_QualityThumb, false, pau_saveWidth, pau_saveHeight, RUF_AspectThumb, pau_nameConflict, ""
  end if
  if RUF_RedirectURL <> "" then
    Response.Redirect RUF_RedirectURL
  end if
end if
%>
<%
' *** Edit Operations: declare variables

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId2

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
Dim FormVal

MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (UploadQueryString <> "") Then
  MM_editAction = MM_editAction & "?" & UploadQueryString
End If

' boolean to abort record edit
MM_abortEdit = false

' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: (Modified for File Upload) set variables

If (CStr(UploadFormRequest("MM_insert")) = "register") Then

  MM_editConnection = MM_connDUportal_STRING
  MM_editTable = "USERS"
  MM_editRedirectUrl = "../home/"
  MM_fieldsStr  = "USUARIO|value|SENHA|value|NOME|value|SOBRENOME|value|EMAIL|value|CPF|value|USER_PICTURE|value|ESTADO|value|USER_HEIGHT|value|USER_WIDTH|value|U_DATED|value"
  MM_columnsStr = "USUARIO|',none,''|SENHA|',none,''|NOME|',none,''|SOBRENOME|',none,''|EMAIL|',none,''|CPF|',none,''|USER_PICTURE|',none,''|ESTADO|',none,''|USER_HEIGHT|',none,''|USER_WIDTH|',none,''|U_DATED|',none,NULL"
  
  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
  
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(UploadFormRequest(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And UploadQueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And UploadQueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & UploadQueryString 
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & UploadQueryString 
    End If
  End If

End If
%>

<%
Dim rsType
Dim rsType_numRows

Set rsType = Server.CreateObject("ADODB.Recordset")
rsType.ActiveConnection = MM_connDUportal_STRING
rsType.Source = "SELECT * FROM USERS ORDER BY USUARIO ASC"
rsType.CursorType = 0
rsType.CursorLocation = 2
rsType.LockType = 1
rsType.Open()

rsType_numRows = 0
%>

<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(UploadFormRequest("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ", U_ACCESS) values (" & MM_dbValues & ", 'USER')"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>
<%
' *** Delete Record: declare variables

if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId2")) <> "") Then

  MM_editConnection = MM_connDUportal_STRING
  MM_editTable = "USERS"
  MM_editColumn = "USUARIO"
  MM_recordId2 = "" + Request.Form("MM_recordId2") + ""
  MM_editRedirectUrl = "typesimage.asp"

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
  
End If
%>

<%
' *** Insert Record: construct a sql insert statement and execute it

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""	
  MM_dbValues = ""
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End if
    MM_tableValues = MM_tableValues & MM_columns(i)
    MM_dbValues = MM_dbValues & FormVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ", U_ACCESS) values (" & MM_dbValues & ", 'USER')"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

Como reorganizei e mudou a linha, o erro é o mesmo: MM_editCmd.Execute

<%
' *** Insert Record: (Modified for File Upload) construct a sql insert statement and execute it

Dim MM_tableValues
Dim MM_dbValues

If (CStr(UploadFormRequest("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""
  MM_dbValues = ""
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
      MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End If
    MM_tableValues = MM_tableValues & MM_columns(MM_i)
    MM_dbValues = MM_dbValues & MM_formVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ", U_ACCESS) values (" & MM_dbValues & ", 'USER')"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

Engraçado, quando nao tem um usuário na tabela e eu o adiciono incluindo a foto, vai certinho, mas quando existe o usuário ex: joaopedro e eu tento incluir o usuário joaopedro novamente gera o erro.

Compartilhar este post


Link para o post
Compartilhar em outros sites

olha como é feito neste link

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tentei retirar este trecho, mas continua dando erro

If (CStr(Request("MM_insert")) <> "") Then

  ' create the sql insert statement
  MM_tableValues = ""	
  MM_dbValues = ""
  For i = LBound(MM_fields) To UBound(MM_fields) Step 2
    FormVal = MM_fields(i+1)
    MM_typeArray = Split(MM_columns(i+1),",")
    Delim = MM_typeArray(0)
    If (Delim = "none") Then Delim = ""
    AltVal = MM_typeArray(1)
    If (AltVal = "none") Then AltVal = ""
    EmptyVal = MM_typeArray(2)
    If (EmptyVal = "none") Then EmptyVal = ""
    If (FormVal = "") Then
      FormVal = EmptyVal
    Else
      If (AltVal <> "") Then
        FormVal = AltVal
      ElseIf (Delim = "'") Then  ' escape quotes
        FormVal = "'" & Replace(FormVal,"'","''") & "'"
      Else
        FormVal = Delim + FormVal + Delim
      End If
    End If
    If (i <> LBound(MM_fields)) Then
      MM_tableValues = MM_tableValues & ","
      MM_dbValues = MM_dbValues & ","
    End if
    MM_tableValues = MM_tableValues & MM_columns(i)
    MM_dbValues = MM_dbValues & FormVal
  Next
  MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ", U_ACCESS) values (" & MM_dbValues & ", 'USER')"

  If (Not MM_abortEdit) Then
    ' execute the insert
    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_editConnection
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If

End If
%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

vc esta usando o dreamweaver para le criar suas consultas ?

 

muitas vezes ele insere muitas linhas de código, mas apenas crie um SELECT antes para ver se existe os dados se tiver dá mensagem de erro senão faz o INSERT

Compartilhar este post


Link para o post
Compartilhar em outros sites

Será que tem algo a ver com meu formulário?

<form action="<%=MM_editAction%>" method="POST" enctype="multipart/form-data" name="register" onSubmit="checkFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','USER_WIDTH','USER_HEIGHT');return document.MM_returnValue" id="register" >
<table border="0" width="100%" border="0" cellspacing="3" cellpadding="0">
	<tr>
		<td class="form_lario">USUÁRIO:</td>
		<td><input name="USUARIO" type="text" class="formcadastro" value="" size="12" maxlength="15"></td>
		<td class="form_lario">SENHA:</td>
		<td><input name="SENHA" type="password" class="formcadastro" value="" size="12" maxlength="15"></td>
	</tr>
	<tr>
		<td class="form_lario">FOTO:</td>
		<td colspan="3"><input name="USER_PICTURE" type="file"  id="USER_PICTURE" onChange="checkOneFileUpload(this,'GIF,JPG,JPEG,BMP,PNG',true,'','','','','','USER_WIDTH','USER_HEIGHT')" size="30"></td>
	</tr>
	<tr>
		<td colspan="4" class="form">*Se não enviar uma foto, o sistema colocará uma padrão no seu perfil</td>
	</tr>
	<tr>
		<td class="form_lario">NOME:</td>
		<td><input name="NOME" type="text" class="formcadastro" value="" size="12" maxlength="15"></td>
		<td class="form_lario">SOBRENOME:</td>
		<td><input name="SOBRENOME" type="text" class="formcadastro" value="" size="12" maxlength="15"></td>
	</tr>
	<tr>
		<td class="form_lario">E-MAIL:</td>
		<td><input name="EMAIL" type="text" class="formcadastro" value="" size="12" maxlength="50"></td>
		<td class="form_lario">ESTADO</td>
		<td><select name="ESTADO" type="text" class="form" >
		<option value="">Selecione</option> 
		<option value="Acre">Acre</option> 
		<option value="Alagoas">Alagoas</option> 
		<option value="Amazonas">Amazonas</option> 
		<option value="Amapá">Amapá</option> 
		<option value="Bahia">Bahia</option> 
		<option value="Ceará">Ceará</option> 
		<option value="Distrito Federal">Distrito Federal</option> 
		<option value="Espírito Santo">Espírito Santo</option> 
		<option value="Goiás">Goiás</option> 
		<option value="Maranhão">Maranhão</option> 
		<option value="Mato Grosso">Mato Grosso</option> 
		<option value="Mato Grosso do Sul">Mato Grosso do Sul</option> 
		<option value="Minas Gerais">Minas Gerais</option> 
		<option value="Pará">Pará</option> 
		<option value="Paraíba">Paraíba</option> 
		<option value="Paraná">Paraná</option> 
		<option value="Pernambuco">Pernambuco</option> 
		<option value="Piauí">Piauí</option> 
		<option value="Rio de Janeiro">Rio de Janeiro</option> 
		<option value="Rio Grande do Norte">Rio Grande do Norte</option> 
		<option value="Rondônia">Rondônia</option> 
		<option value="Rio Grande do Sul">Rio Grande do Sul</option> 
		<option value="Roraima">Roraima</option> 
		<option value="Santa Catarina">Santa Catarina</option> 
		<option value="Sergipe">Sergipe</option> 
		<option value="São Paulo">São Paulo</option> 
		<option value="Tocantins">Tocantins</option> 
</select></td>
	</tr>
	<tr>
		<td class="form_lario">CPF:</td>
		<td><input name="CPF" type="text" class="formcadastro" value="Apenas números" size="12" maxlength="11" onBlur="ValidarCPF2(register.CPF);" onKeyPress="MascaraCPF(register.CPF);"></td>
		<td></td>
		<td><input name="Register" type="submit" class="button" id="Register" onClick="MM_validateForm('USUARIO','','R','SENHA','','RinRange','NOME','','R','SOBRENOME','','R','EMAIL','','RisEmail','CPF','','RinRange','ESTADO','','R');return document.MM_returnValue" value="Enviar cadastro"></td>
	</tr>
	<tr>
		<td colspan="4" class="form_lario">
		<% If Request.QueryString("requsername") <> "" Then %>
		(Ooops!: Nosso sistema identificou que já existe um usuário com este nome,<a id="fontemenu" href="../home/password.asp">se for o dono deste usuário, basta clicar aqui e reenviar a senha.</a>)
		<% End If %>
		<% If Request.QueryString("reqemail") <> "" Then %>
		(Ooops!: Nosso sistema identificou que este e-mail já possui cadastro no site,<a id="fontemenu"href="../home/password.asp">para recuperar sua senha é fácil: basta clicar aqui.</a>)
		<% End If %>
		</td>
	</tr>
		</table>
<input type="hidden" name="U_DATED" value="<%= date() %>" size="32"> 
<input type="hidden" name="MM_insert" value="register">
</form>

ao retirar esta instrução:

<input type="hidden" name="U_DATED" value="<%= date() %>" size="32"> 
<input type="hidden" name="MM_insert" value="register">

ele não grava ne usuários novos e nem antigos e aponta erro na linha 258: Não é possível usar a coleção genérica Request

 

Linha:

 if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId2")) <> "") Then

Código do erro em questão:

<%
' *** Delete Record: declare variables

if (CStr(Request("MM_delete")) <> "" And CStr(Request("MM_recordId2")) <> "") Then

  MM_editConnection = MM_connDUportal_STRING
  MM_editTable = "USERS"
  MM_editColumn = "USUARIO"
  MM_recordId2 = "" + Request.Form("MM_recordId2") + ""
  MM_editRedirectUrl = "typesimage.asp"

  ' append the query string to the redirect URL
  If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
    End If
  End If
  
End If
%>

<%

Compartilhar este post


Link para o post
Compartilhar em outros sites

dá pra usar só o request, mas é melhor e mais adequado usar o .form ou .querystring (esse quando vier pela URL)

 

e essa linha esta pegando apenas a data atual. Depois quando chegar em casa coloco aquele código do link que esta quebrado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.