Jump to content

Erro Microsoft SQL Native Client (0x80040E10)


chell515
 Share

Recommended Posts

Boas,

Criei uma página ASP em que preciso de criar certos parâmetros e enviá-los para o SQL e correr um Store Procedure, mas tenho um erro que não estou a conseguir corrigir e agradecia um pouco da vossa ajuda pfv.

O erro que me está a ocorrer é o seguinte:

Microsoft SQL Native Client (0x80040E10)

Procedure or function 'Insert_Cliente' expects parameter '@nome', which was not supplied.

/contactos/ContactosPOST_Insert.asp, line 60

Página ASP:


<!--metadata type="typelib" file="c:\program files\common files\system\ado\msado15.dll" -->
<!--METADATA TYPE="typelib" NAME="Microsoft ActiveX Data Objects 2.8 Library" UUID="{2A75196C-D9EB-4129-B803-931327F72D5C}" VERSION="2.8"-->
<%
Dim myconn
Dim connectString
Dim hobbieAll

Set myconn = Server.CreateObject("ADODB.Connection")
connectString = "Provider=SQLNCLI;" & "Server=172.30.40.53;" & "Database=ANDROTeste;" & "Uid=UAndroTeste;" & "Pwd=UAndroTeste;"
myconn.Open(connectString)

Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = myconn
cmd.CommandText = "Insert_Cliente"
cmd.CommandType = adCmdStoredProc

cmd.Parameters.Append cmd.CreateParameter("@nome", adVarChar, adParamInput,250,nome)
cmd.Parameters.Append cmd.CreateParameter("@morada", adVarChar, adParamInput,250,morada)
cmd.Parameters.Append cmd.CreateParameter("@contacto", adVarChar, adParamInput,9,contacto)
cmd.Parameters.Append cmd.CreateParameter("@email", adVarChar, adParamInput,50,email)
cmd.Parameters.Append cmd.CreateParameter("@estado_civil_id", adInteger,adParamInput,,estadocivil)
cmd.Parameters.Append cmd.CreateParameter("@profissao_id", adInteger, adParamInput,,profissao)
cmd.Parameters.Append cmd.CreateParameter("@dataNasc", adDate,adParamInput)
cmd.Parameters.Append cmd.CreateParameter("@hobbies",adVarChar,adParamInput,250,hobbie)

cmd("@nome") = Request.Form("txtnome")
cmd("@morada") = Request.Form("txtmorada")
cmd("@contacto") = Request.Form("txtcontacto")
cmd("@email") = Request.Form("txtemail")
cmd("@estado_civil_id") = Request.Form("ddlestadocivil")
cmd("@profissao_id") = Request.Form("ddlprofissao")
cmd("@dataNasc") = Request.Form("txtdatanascimento")

if Request.Form("chkhobbie01") = 1 then
hobbieAll = Request.Form("chkhobbie01")& ","
end if

if Request.Form("chkhobbie02") = 2 then
hobbieAll = hobbieAll & Request.Form("chkhobbie02")& ","
end if

if Request.Form("chkhobbie03") = 3 then
hobbieAll = hobbieAll & Request.Form("chkhobbie03")& ","
end if

if Request.Form("chkhobbie04") = 4 then
hobbieAll = hobbieAll & Request.Form("chkhobbie04")& ","
end if

if Request.Form("chkhobbie05") = 5 then
hobbieAll = hobbieAll & Request.Form("chkhobbie05")& ","
end if

if Request.Form("chkhobbie06") = 6 then
hobbieAll = hobbieAll & Request.Form("chkhobbie06")
end if

cmd("@hobbies") = hobbieAll

cmd.Execute <===== LINHA 60

myconn.Close()
Set myconn = Nothing

Response.Redirect("http://localhost/contactos/Contactos.asp")
%>

A minha store procedure está feita da seguinte forma:

ALTER PROCEDURE [dbo].[insert_Cliente]
@nome				nvarchar(250),
@morada				nvarchar(250),
@contacto			nvarchar(9),
@email				nvarchar(50),
@estado_civil_id	int,
@profissao_id		int,
@dataNasc			date,
@hobbies			nvarchar(20)		
AS
DECLARE @clienteID		varchar(max)

INSERT INTO LC_Clientes (Nome, Morada,Contacto, Email, EstadoCivilID, ProfissaoID, DataNascimento)
VALUES (@nome, @morada, @contacto, @email, @estado_civil_id, @profissao_id, @dataNasc)
SELECT SCOPE_IDENTITY()
SET @clienteID = SCOPE_IDENTITY()

DECLARE @pos			integer = 1
DECLARE @previous_pos	integer = 0
DECLARE @value			int

BEGIN
WHILE @pos > 0
BEGIN
	SET @pos = CHARINDEX(',',@hobbies,@previous_pos+1)
	IF @pos > 0	
	BEGIN
		SET @value = SUBSTRING(@hobbies,@previous_pos+1,@pos-@previous_pos-1)		
		INSERT INTO LC_RelClienteHobbie VALUES (@clienteID, @value)
		SET @previous_pos = @pos
	END
END
IF @previous_pos < LEN(@hobbies)
BEGIN
	SET @value = SUBSTRING(@hobbies,@previous_pos+1,LEN(@hobbies))		
	INSERT INTO LC_RelClienteHobbie VALUES (@clienteID, @value)
END
END

Obrigado pela ajuda e pelo tempo despendido 😛

Cumpz

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.