Results 1 to 5 of 5

Thread: Insert failed

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Insert failed

    Hi

    I have SQL Server 2000 table "FilePerson" that contains a field of type varbinary.I want to insert into that field a value like "C:\xx.xls" but the insert failed.
    the following message appeared:
    Insert into FilePerson(_ID,_Path) VALUES('4','c:\xxx.xls')

    Disallowed implicit conversion from data type varchar to data type varbinary, table 'FilePerson', column '_Path'. Use the CONVERT function to run this query.

    Any help
    thanks

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Insert failed

    The error message is self explanatory, just google http://msdn.microsoft.com/en-us/libr...4(SQL.80).aspx

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Insert failed

    Moved to Database Development

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Insert failed

    If it's asking for VARBINARY then it may be that your data type for _Path is not varchar but is varbinary. We shouldn't have to be guessing this though, you should be telling us what the datatypes for your table columns are.

    If it is indeed VARBINARY then it is expecting the actual binary data of the file, not the path to the file. You will need to read that file c:\xxx.xls into a stream into a byte array and then pass that in your statement.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2006
    Posts
    977

    Re: Insert failed

    mendhak
    _Path is varbinary.
    You will need to read that file c:\xxx.xls into a stream into a byte array
    how can I read te file into a byte array
    thanks

Posting Permissions

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



Click Here to Expand Forum to Full Width