Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2004
    Posts
    12

    Unanswered: Type mismatch...hell oh hell

    hi all,

    ive been having this problem recently and havnt been able to hunt down a solution for it....

    i have a table. 3 columns. name(varchar),age(int) and job(varchar)

    i have a stored procedure which takes in name age and job from a form and attemps to through them into the db,but its giving me...

    Parameter object is improperly defined. Inconsistent or incomplete information was provided.

    or
    Type Mismatch..
    lovely!

    Here's some code for the sproc
    Code:
    CREATE proc sp_insertinfo
    @name varchar(50),
    @age int,
    @job varchar(50)
    
    as
    
    insert into users
    values (@name,@age,@job)
    
    GO
    
    
    and for the actual ASP file...
    
    
    		 
    	strConn="Provider=SQLOLEDB;User ID=sa; Password=xxxxx; Initial Catalog=Skills; Data Source=xxxxx"
    	oConn.Open strConn
    	Set oCmd.ActiveConnection = oConn
    
    	'assign form info to params
    
    	name=Request.Form("name")
    	age=Request.Form("age")
    	job=Request.Form("job")
    
    
    
    	'call sproc
    
    	oCmd.CommandText = "call sp_insertinfo @name,@age,@job"
    
    	'Append params	
    
    
    	oCmd.Parameters.Append oCmd.CreateParameter("name", adVarChar, adParamInput, 50, name) 
    	oCmd.Parameters.Append oCmd.CreateParameter("age", adInteger, adParamInput,4,age) 
    	oCmd.Parameters.Append oCmd.CreateParameter("job", adVarChar, adParamInput, 50, job) 
    
    	'execute the sproc with the params
    	
    	Set oRs = oCmd.Execute

    Anyways it would be great if you could check that out there. Any help def appreciated as this "simple" prob is holding me up big style!

    Cheers!
    damalo
    Last edited by damalo; 04-14-04 at 07:50.

  2. #2
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34

    Question Q?

    Have you defined oCmd?

  3. #3
    Join Date
    Apr 2004
    Posts
    12

    Re: Q?

    Originally posted by SQLSurfer
    Have you defined oCmd?

    Code:
    	                                Dim oConn	
    			Dim strConn	
    			Dim oCmd	
    			Dim oRs		
    			Dim name,job,age
    			Dim adInteger,adVarChar
    
    			Set oConn = Server.CreateObject("ADODB.Connection")
    			Set oCmd = Server.CreateObject("ADODB.Command")
    yes...

  4. #4
    Join Date
    Apr 2004
    Posts
    12

    Re: Q?

    im told i should have defined the adInteger and adVarchar somewhere...is there some sort of header include file that would do the job?

  5. #5
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34

    Re: Q?

    Originally posted by damalo
    im told i should have defined the adInteger and adVarchar somewhere...is there some sort of header include file that would do the job?
    Have not done this for a while but seem to remember defining parameter objects like'

    dim prm1 as adodb.parameter
    dim prm2 as adodb.parameter

    set prm1 = oCmd.CreateParameter("name", adVarChar, adParamInput, 50, name)

    set prm2 = oCmd.CreateParameter("age", adInteger, adParamInput,4,age)

    oCmd.Parameters.Append prm1
    oCmd.Parameters.Append prm2

    does that look familiar

  6. #6
    Join Date
    Apr 2004
    Posts
    12
    nope..feck! lol

    i was looking at this...

    http://msdn.microsoft.com/library/de...dooverview.asp

    and was down in enumerated constants,im not sure where to go from there though.tried that thing you showed me but it complained about some syntax

  7. #7
    Join Date
    Mar 2004
    Location
    West London
    Posts
    34
    Originally posted by damalo
    nope..feck! lol

    i was looking at this...

    http://msdn.microsoft.com/library/de...dooverview.asp

    and was down in enumerated constants,im not sure where to go from there though.tried that thing you showed me but it complained about some syntax
    stick @ in front of the parameters your passing:
    oCmd.Parameters.Append oCmd.CreateParameter("@name", adVarChar, adParamInput, 50, name)

  8. #8
    Join Date
    Apr 2004
    Posts
    12
    nope, im afraid im getting...

    "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another"


    i wonder what the hell it is...im still looking into trying to define the adVarChar as when i print them out i dont get a value for them. hmm!

    continued thanks!

  9. #9
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Have you tested your stored procedure directly by calling it from Query Analyzer?

    I'm not sure if this syntax even works, but it's not a syntax I would use because it is not very specific:

    insert into users
    values (@name,@age,@job)

    Better would be this:

    insert into users (NameField, AgeField, JobField)
    values (@name,@age,@job)

    When you don't specify the fields in which to insert the data, the server assumes that the parameters you supply match the columns in the table in order and datatype. This is not always the case, and thus good programming practice is to specify the matching to be used.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  10. #10
    Join Date
    Apr 2004
    Posts
    12
    yes i did that for sure.Its the first thing i do before integrating it into the asp code. Thanks for the reply

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •