473,568 Members | 2,882 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4706
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...@martinhors t.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
5812
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"); stream_set_timeout($con,0,$us); fwrite($con"\xff\info\"); $retval = fgets($con,10240); My problem is that I allways have to wait for $us seconds.
3
1726
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 books where title like '"&%title%&"' ORDER BY title "
2
6930
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 server, it still uses paging file space, a lot. When looking thru task maanger we can see sql server using 15.5GB of Memory usage and 22GB of...
5
16382
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 to save an picture in this field, and then show this picture by an datagrid or other control.... (for each record desirable) Does anybody knows how...
2
6530
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
4773
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 inserted to the field and then read back and converted to original format. If you can do this - may your children be superheroes
0
1216
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 now I do not have access to the server using an SQL Server user account and am using the Windows Authentication. Any help appreciated. Siv
0
1307
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 schema is very set in stone, I can't do anything with it. I'm currently opening autogenerated SQL scripts, decoding them from utf-16 and then back into...
1
6418
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) field I am trying to update. Here's how I'm doing it. I have a strongly typed dataset in c#. The column in question is defined as ...
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
932
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.