Ir para conteúdo

POWERED BY:

Arquivado

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

tr374

mudei para o caminho físico

Recommended Posts

mudei recentemente o arquivo que abre a conexão com o BD, pois mudei o BD de lugar.

 

de

ASP [/tr][tr]'Set DB = Server.CreateObject("ADODB.Connection")

'cnpath="DBQ=" & server.mappath("c-banco.mdb")

'DB.Open "DRIVER={Microsoft Access Driver (*.mdb)}; " & cnpath

[/tr]

 

para

ASP [/tr][tr]ConnString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\Inetpub\clientes\meu_site.com.br\data\c-banco.mdb;"

Set DB = Server.CreateObject("ADODB.Connection")

DB.Open ConnString

[/tr]

 

Resumindo mudei para o caminho físico.

 

Mas, apesar do site estar funcionando, as opções incluir, deletar e update não estão mais funcionando:

Exemplo (que estava funcionado antes da alteração):

ASP [/tr][tr]alterar = "UPDATE DISTINCTROW tabela_1 SET nome = '" & nome & "', datainicio = '" & datainicio & "', status2 = '" & status2 & "', obs = '" & obs & "', link = '" & link & "' WHERE codigo = " & (codigo) & ""

DB.Execute(alterar)

[/tr]

 

Alguem poderia me ajudar me dizendo o que teria que mudar para esses três comandos funcionarem ?

 

desde já obrigado.

Compartilhar este post


Link para o post
Compartilhar em outros sites

esta apresentando alguma mensgaem de erro??

Compartilhar este post


Link para o post
Compartilhar em outros sites

Sim, esta apresentando os erros:

 

no insert:

Microsoft JET Database Engine error '80040e14'

Syntax error in INSERT INTO statement.

/inclui.asp, line 24

no update:

Microsoft JET Database Engine error '80040e14'

Syntax error in UPDATE statement.

/alterar.asp, line 24

as linhas 24 são exatamente as do Execute

Compartilhar este post


Link para o post
Compartilhar em outros sites

Acredito que sim, postei o meu update lá em cima:

 

ASP [/tr][tr]alterar = "UPDATE DISTINCTROW tabela_1 SET nome = '" & nome & "', datainicio = '" & datainicio & "', status2 = '" & status2 & "', obs = '" & obs & "', link = '" & link & "' WHERE codigo = " & (codigo) & ""

DB.Execute(alterar)

[/tr]

Compartilhar este post


Link para o post
Compartilhar em outros sites

é, acho que nao existe distincrow no update.... e mostre as String SQL que voce esta mandando para o banco, mas o codigo gerado, nao o codigo fonte da String SQL...nao mostra a variavelalterar="update ...."somenteresponse.Write alterar <-- sua variavel de String SQLfalow?

Compartilhar este post


Link para o post
Compartilhar em outros sites

comando UPDATE e INSERT no SQL Server....

 

UPDATEThe UPDATE statement changes data in the row where the cursor is currently positioned.SyntaxUPDATE {table_name | view_name} SET {column=expression[,...]} WHERE CURRENT OF cursor_nameArgumentstable_nameIs the table to be updated.view_nameIs the view to be updated.columnIs the column to be updated.expressionIs the value of a particular column name. This value can be an expression or a null value.cursor_nameIs a previously declared, opened, and fetched cursor.

INSERTAdds a new row to a table or a view.SyntaxINSERT [ INTO]     { table_name WITH ( < table_hint_limited > [ ...n ] )         | view_name         | rowset_function_limited     }     {    [ ( column_list ) ]         { VALUES             ( { DEFAULT | NULL | expression } [ ,...n] )             | derived_table             | execute_statement         }     }     | DEFAULT VALUES < table_hint_limited > ::=     { FASTFIRSTROW         | HOLDLOCK         | PAGLOCK         | READCOMMITTED         | REPEATABLEREAD         | ROWLOCK         | SERIALIZABLE         | TABLOCK         | TABLOCKX         | UPDLOCK     } Arguments[INTO] Is an optional keyword that can be used between INSERT and the target table.table_nameIs the name of a table or table variable that is to receive the data. WITH (<table_hint_limited> [...n])Specifies one or more table hints that are allowed for a target table. The WITH keyword and the parentheses are required. READPAST, NOLOCK, and READUNCOMMITTED are not allowed. For more information about table hints, see FROM.view_nameIs the name and optional alias of a view. The view referenced by view_name must be updatable. The modifications made by the INSERT statement cannot affect more than one of the base tables referenced in the FROM clause of the view. For example, an INSERT into a multitable view must use a column_list that references only columns from one base table. For more information about updatable views, see CREATE VIEW. rowset_function_limitedIs either the OPENQUERY or OPENROWSET function. For more information, see OPENQUERY and OPENROWSET. (column_list)Is a list of one or more columns in which to insert data. column_list must be enclosed in parentheses and delimited by commas. If a column is not in column_list, Microsoft® SQL Server™ must be able to provide a value based on the definition of the column; otherwise, the row cannot be loaded. SQL Server automatically provides a value for the column if the column: Has an IDENTITY property. The next incremental identity value is used.Has a default. The default value for the column is used.Has a timestamp data type. The current timestamp value is used.Is nullable. A null value is used. column_list and VALUES list must be used when inserting explicit values into an identity column, and the SET IDENTITY_INSERT option must be ON for the table.VALUES Introduces the list of data values to be inserted. There must be one data value for each column in column_list (if specified) or in the table. The values list must be enclosed in parentheses.If the values in the VALUES list are not in the same order as the columns in the table or do not have a value for each column in the table, column_list must be used to explicitly specify the column that stores each incoming value.DEFAULTForces SQL Server to load the default value defined for a column. If a default does not exist for the column and the column allows NULLs, NULL is inserted. For a column defined with the timestamp data type, the next timestamp value is inserted. DEFAULT is not valid for an identity column.expressionIs a constant, a variable, or an expression. The expression cannot contain a SELECT or EXECUTE statement.derived_tableIs any valid SELECT statement that returns rows of data to be loaded into the table.execute_statementIs any valid EXECUTE statement that returns data with SELECT or READTEXT statements.If execute_statement is used with INSERT, each result set must be compatible with the columns in the table or in column_list. execute_statement can be used to execute stored procedures on the same server or a remote server. The procedure in the remote server is executed, and the result sets are returned to the local server and loaded into the table in the local server. If execute_statement returns data with the READTEXT statement, each individual READTEXT statement can return a maximum of 1 MB (1024 KB) of data. execute_statement can also be used with extended procedures, and inserts the data returned by the main thread of the extended procedure. Output from threads other than the main thread are not inserted.Note  For SQL Server version 7.0, execute_statement cannot contain an extended stored procedure that returns text or image columns. This behavior is a change from earlier versions of SQL Server.DEFAULT VALUESForces the new row to contain the default values defined for each column.

abracos

Compartilhar este post


Link para o post
Compartilhar em outros sites

Abaixo o resposne.write de alterar

 

ASP [/tr][tr]UPDATE DISTINCTROW tabela_1 SET nome = 'Nome Teste', datainicio = '21/12/2004', status2 = 'presencial', obs = 'obs', link = 'teste.asp' WHERE codigo = 1[/tr]

 

O banco de dados é em access, mas como disse antes, estava tudo funcionando antes de mudar o diretório do BD.

Compartilhar este post


Link para o post
Compartilhar em outros sites

entonces....tira o distinctrow e ve se funciona...como te passei, o comando UPDATE nao aceita o DISTINCTROW, nem o ACCESS, nem o SQL SERVER.... provavelmente nao estava funcionando corretamente....

Compartilhar este post


Link para o post
Compartilhar em outros sites

O problema é que ao mudares o caminho físico, alteraste as permissões de acesso ao ficheiro, assim passaste a poder ler (fazer SELECT) mas não podes alterar (UPDATE,INSERT,DELETE)Volta à tua forma inicial e muda esta linha cnpath="DBQ=" & server.mappath("c-banco.mdb")para cnpath="DBQ=" & server.mappath("caminho/para/bd/c-banco.mdb")

Compartilhar este post


Link para o post
Compartilhar em outros sites

Turma obrigado pela ajuda, o erro estava mesmo no começo.Agora aqui funcionou, mesmo com o DISTINCTROW, que sinceramente não sei para que serve.

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.