+ Reply to Thread
Results 1 to 10 of 10

Thread: Conversion failed when converting the varchar error

  1. #1
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    Conversion failed when converting the varchar error

    hi

    below is my procedure i m getting conversion error .how to resolve this?


    Code:
    CREATE PROCEDURE pr_ProductGLCategoryData_Import
    
    @vnMemberID INT, 
    
    @vnSupplierID INT,
    
    @vsProductCode VARCHAR(50),
    
    @vnIsStock bit=0,
    
    @vsGLCategoryCode VARCHAR(1000),
    
    @vsResult VARCHAR(1000) OUTPUT
    
    AS
    
     
    
    SET NOCOUNT ON
    
    SET @vnIsStock = IsNull(@vnIsStock,0)
    
    Set @vsResult = ''
    
    Set @vsResult = 'Supplier Code / ' + cast(IsNull(str(@vnSupplierID),'<blank>') AS Varchar) + CHAR(10)
    


    getting this error

    Msg 245, Level 16, State 1, Procedure pr_ProductGLCategoryData_Import, Line 63

    Conversion failed when converting the varchar value 'Supplier Code / 11

    ' to data type int.
    Love is physical attraction and mental destruction

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    try this:

    Code:
    SET @vsResult = 'SupplierCode /' + CAST(ISNULL(@vnSupplierID,'<blank>') As VarChar) + CHAR(10)
    
    I tested the above and worked fine for me.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    thanks for reply.actaully problem was with Return statement.if i use like this
    Return @vsResult then it give error.if i use only return statement then it works.

    so now its working.
    Love is physical attraction and mental destruction

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by guddu View Post
    thanks for reply.actaully problem was with Return statement.if i use like this
    Return @vsResult then it give error.if i use only return statement then it works.

    so now its working.
    Ahhh that's because you can only Return integers, thus having to set @vsResult as an OUTPUT parameter.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  5. #5
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    yes u are rite.but now i m facing a new problem in front end.
    'SUPPLIER CODE / ' + ISNULL(CONVERT(VARCHAR,@vnSupplierID),'<BLANK>')

    procedure returns this string well butin my output from front end <BLANK> tag is not showing.instead it show space i meant not showing <blank> tag.

    why?
    Love is physical attraction and mental destruction

  6. #6
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by guddu View Post
    yes u are rite.but now i m facing a new problem in front end.
    'SUPPLIER CODE / ' + ISNULL(CONVERT(VARCHAR,@vnSupplierID),'<BLANK>')

    procedure returns this string well butin my output from front end <BLANK> tag is not showing.instead it show space i meant not showing <blank> tag.

    why?
    Try using Server.HtmlEncode on the output and see if it displays then.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  7. #7
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    woh again sorry jmh.its in vb dear.
    Love is physical attraction and mental destruction

  8. #8
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Okay, looking at this again, the only way <blank> will be returned is if @vnSupplierID is NULL. So, if this isn't being passed to the procedure as NULL, then it won't return <blank> in the string.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  9. #9
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    that is no an issue.actuall when i execute procedure at analyzer its working and in case of null it returns <blank> tag.but in my vb output it does not showing that tag.
    Love is physical attraction and mental destruction

  10. #10
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Are you sure that the variable that you are passing to the procedure in VB actually is a NULL value? If the procedure works as expected, then this is no longer a SQL problem. Post a question in the Visual Basic forum with the relevant code.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread

Similar Threads

  1. Error Type:Active Server Pages, ASP 0113 (0x80004005)
    By guddu in forum ASP Development
    Replies: 20
    Last Post: July 11th, 2008, 10:44 AM
  2. query error
    By todd2006 in forum SQL Development
    Replies: 1
    Last Post: June 24th, 2008, 01:05 PM
  3. XML Node Error
    By noFriends in forum Visual Basic Programming
    Replies: 4
    Last Post: June 3rd, 2008, 09:57 AM
  4. Wizard1 error The command 'MoveComplete' is not valid
    By peebman2000 in forum .NET Development
    Replies: 10
    Last Post: April 28th, 2008, 03:52 PM
  5. Replies: 2
    Last Post: March 16th, 2008, 11:18 AM

Bookmarks

Posting Permissions

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

SEO by vBSEO