473,396 Members | 2,029 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,396 software developers and data experts.

Strange Access DB Updat Behavior :-(

Somebody please explain this to me:

I've got an Access database with a table containing some 20 fields. A few
are boolean and integer, but most of them are string(50). And then I've got
one field that is a PM (Memo) field. That one is supposed to contain image
data in string format and the length of my "testimage" string was around
5600 characters.

To update the table I had an OleDbCommand:

myCommand.CommandText="UPDATE tblFoo SET Field1=@Data1, Field2=@Data2 ...
etc... Field19=@Data19, ImageField=@ImageData WHERE RowID=12" (e.g.)

myCommand.Parameters.AddWithValue("@Data1", "teststring1 teststring1
teststring1 teststring1")
myCommand.Parameters.AddWithValue("@Data2", "teststring2 teststring2
teststring2 teststring2")
..
..
..
myCommand.Parameters.AddWithValue("@Data19", "teststring19 teststring19
teststring19 teststring19")
myCommand.Parameters.AddWithValue("@ImageData", "This is my 5600 character
long string containing image data")

myCommand.ExecuteNonQuery

This should work. I've tested it by JUST updating the image string, and
there's no problem. But when I add all the other parameters, suddenly the
ImageData field doesn't contain "This is my 5600 character long string
containing image data" but "0" or "1".

I don't get any error message, just a weird behavior. If I split it up into:

myCommand.CommandText="UPDATE tblFoo SET Field1=@Data1, Field2=@Data2 ...
etc... Field19=@Data19 WHERE RowID=12"

myCommand.Parameters.AddWithValue("@Data1", "teststring1 teststring1
teststring1 teststring1")
myCommand.Parameters.AddWithValue("@Data2", "teststring2 teststring2
teststring2 teststring2")
..
..
..
myCommand.Parameters.AddWithValue("@Data19", "teststring19 teststring19
teststring19 teststring19")

myCommand.ExecuteNonQuery

myCommand.Parameters.Clear

myCommand.CommandText="UPDATE tblFoo SET ImageField=@ImageData WHERE
RowID=12"

myCommand.Parameters.AddWithValue("@ImageData", "This is my 5600 character
long string containing image data")

myCommand.ExecuteNonQuery

THEN everything works! Can anybody explain this to me? No error message...

Is there a maximum size for the OleDbCommand Param collection and if there
is, why don't I get an error message?

I've wasted two days on this now, and would really like to know why.

Bewildered,
Johnny
Dec 7 '07 #1
1 973
Johnny,
Be aware that parameters in OleDB have names, however those do nothing,
therefore you see often an ? in meant for OleDB SQL scripts.

You have to add the parameters in the same sequence as they appear in the
SQL script.

Cor

Dec 8 '07 #2

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

Similar topics

5
by: Bill Grigg | last post by:
I am attempting to set the UnicodeCompression property via code. The following line "appears" to work: tdf.Fields("State").Properties("UnicodeCompression").Value = True I can see the boolean...
3
by: Dalan | last post by:
At first I was not certain what could cause Access 97 from displaying most jpeg images, but not all. After further testing, it seemed that all original images of less than 275 pixels per inch or...
0
by: William Wisnieski | last post by:
Hello Everyone: I'm having a very strange problem occurring with my Access 2000 database. I call it the "mystery record." Here's the story: I have a query by form that returns a record set...
0
by: L Scott | last post by:
Have developed a c# / asp.net web app. Works locally. But over the internet when I access the site, it eventually returns a 'The page cannot be displayed' page. Not always on the same page. Can...
2
by: Jim Bancroft | last post by:
Hi everyone, I have a DropDownList I populate as outlined below. This is from my code-behind file: private void Page_Load(object sender, System.EventArgs e) { BindMyData(); DataBind(); }
2
by: Nir.Hazan | last post by:
When I try to update my GridView I get the error: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: CustomerID, EmployeeID, OrderDate,...
8
by: FBM | last post by:
Hi there, I am puzzled with the behavior of my code.. I am working on a networking stuff, and debugging with eclipse (GNU gdb 6.6-debian).. The problem I am experiencing is the following: ...
0
by: asad56 | last post by:
I am workin with a superstore managment project. I connect Access database with main form . Then it work properly. But now I connect same database with another table or field in another form which is...
160
by: DiAvOl | last post by:
Hello everyone, Please take a look at the following code: #include <stdio.h> typedef struct person { char name; int age; } Person;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.