473,326 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problems with writing an SQL Server varbinary(max) field using .Net1.1

Hi,

I've got an application which is written in .Net 1.1. When I try to
write a varbinary(max) field using the SqlCommand and SqlParameter
classes I got an exception like this:

"The conversion of varchar into varbinary is invalid".

When I remove this field from my update statement, everything works
fine. The SQL paramter got the the DbNull value.
In the moment it is not possible for me to use another .Net framework,
because of the use of older external libraries. Has someone an idea what
I can do. In the moment I'm running out of time.

Thanks in advance
Martin
Jun 27 '08 #1
4 4678
What is the DbType on the parameter?
Jun 27 '08 #2
Hi,

Marc Gravell schrieb:
What is the DbType on the parameter?
good idea. That's the problem. The default is string and is not changed,
if the value is DbNull. My problem now is, that this methode, where I'm
creating and executing the SqlCmmand is generic. Is a value is null I
don't have a chance to determine the type of the value. Any ideas? I
tried setting object but this doesn't work ever. In .Net 2.0 or higher
you don't need to set the DbType if your value is DbNull.

Best regards
Martin
Jun 27 '08 #3
The best thing I can suggest is to write an overload of your "AddParam"
(or whatever) that accepts a byte[], and ensure that it is passed as a
byte[] (not an object) so that the overload gets used. Then in that
overload, at least know know what you are dealing with and can set the
parameter appropriately... not ideal, however...
Jun 27 '08 #4
On Apr 22, 9:33*am, Martin Horst <pub1-R...@martinhorst.dewrote:
Hi,

I've got an application which is written in .Net 1.1. When I try to
write a varbinary(max) field using the SqlCommand and SqlParameter
classes I got an exception like this:

"The conversion of varchar into varbinary is invalid".

When I remove this field from my update statement, everything works
fine. The SQL paramter got the the DbNull value.
In the moment it is not possible for me to use another .Net framework,
because of the use of older external libraries. Has someone an idea what
I can do. In the moment I'm running out of time.

Thanks in advance
Martin
Hi,

IIRC varbinary expect a byte[] , so you can convert your string to
byte[]
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Fred H | last post by:
I'm communicating with a server using UDP, and it can be narrowed down to this: $us = 75000; //Timeout in microseconds. $con = fsockopen("udp://127.0.0.0","23000");...
3
by: Bill | last post by:
I'm trying to pull up all the titles in our database that have a word like the one submitted from our search form. The string is like this: title=request.form("title") sql=" SELECT * FROM...
2
by: GG | last post by:
Hi, We have a prod server running on SQL server 2000 64 bit. It is a 4cpu server with 16GB of RAM. we have a maxmemory setting of 15.5GB for sql server. Inspite of 15GB being available for sql...
5
by: Sukhanov Volodya | last post by:
Hello, all! Does anybody knows, how I can show an image field SQL Server using VB. NET ? I have an database, which has an table with an field which has type 'image' (the type of field) I want...
2
by: Bill Nguyen | last post by:
I need sample code to insert binary file (mappoint map file) into a varbinary column using VB.NET. Please help! Thanks Bill
2
by: tindersticks | last post by:
Hi Can someone please post the simplest script that will allow an asp page read and write to/from m a MS SQL varbinary(max) field. ie image or doc/pdf etc is converted to relevant format and...
0
by: Siv | last post by:
Hi, What is the best way to get the field names of a table in SQL server where you only have Windows Authentication access to a database. Previously I have used the SQLDMO object to get this, but...
0
by: Darren Mansell | last post by:
On Mon, 2008-11-17 at 15:24 +0000, Tim Golden wrote: Thanks for the help. Unfortunately pyodbc seems to only work on Windows. I need to connect to the SQL server from a Linux box. The db...
1
by: quintonmartin | last post by:
Here's my problem. I have a client application that uses a web service for data access. I can read/update many records in many tables, however, I am not getting what I expect for a varbinary(max)...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.