|
No we can't help, not until you actually check that you have data in your byte array.
Byte[] btpht = new Byte[0];
btpht = (Byte[])(ds.Tables["client"].Rows[c - 1]["photo"]); After you step over this line, how many bytes are in btpht? Oh, and you don't need to new up the byte beforehand.
|
|
|
|
|
i don't know what to say in my database, i have only one registration
|
|
|
|
|
WE ARE TRYING TO HELP!!!!!!!!!!!!!!!!!!!!!!
The problem is that you're not listening and you're not doing what we're telling you to do to help diagnose the problem! You're NOT helping us help you!
YOU have to do the work! We don't have access to your machine and we can't see your monitor, so how else is this going to get fixed??
modified 31-Mar-14 10:55am.
|
|
|
|
|
i use Access data-base
and i have used OLE object in my image data
|
|
|
|
|
when I created my data base in access, is displaying binary data (my image data)
|
|
|
|
|
You still haven't told us if you've stepped over that line of code and checked the size of it. We aren't trying to trick you here. You really do need to check that you've populated it first.
|
|
|
|
|
i said that until now, just one picture in my database
|
|
|
|
|
But is that picture actually making it through to your code? That's what we have been trying to get you to check. Look, do what I asked and put a breakpoint on your code and step over that line - then check how big your byte array is. It's not difficult. I'm not asking you to rewire the space shuttle. I'm just asking you to check that you are getting, in this field, what you would be expecting. Then, if you are, we have ruled out one problem and we can move onto potential causes.
|
|
|
|
|
Nobody, and especially your application, cares what YOU think is in the database. What is at hand is what the CODE thinks! And you're not even attempting to answer that question.
|
|
|
|
|
Do you know what debugging is?
It means you run the program, but stop it at some point (it is called a breakpoint). Then you can execute the code line by line and check the values of the variables (right-click - quickwatch).
What Pete and Dave are trying to explain is that the bytes that are in the database need to be copied into your code (adpt.Fill(ds, "client");). If that didn't work than the conversion from Byte[] to Image won't work.
So their question is: What is the "Length" of the btpht object AFTER this line: btpht = (Byte[])(ds.Tables["client"].Rows[c - 1]["photo"]);
Hope this helps.
(PS: respond to them the answer, not to this message)
|
|
|
|
|
until now i don't have an idea because it's my first time to use it, can't you tell me how to do about "LENGTH"?????
|
|
|
|
|
yes, I can.
Read a book.
I'm serious. You're lacking some basic knowledge, hence you don't understand what people are telling you.
If you cannot grasp the notion of a Length property of an array, contacting databases is way over your head.
Read a book and start from scratch. Create a "hello world" program and work your way up.
|
|
|
|
|
Then you should have said that you had no idea what how to use the debugger LONG before this.
|
|
|
|
|
Open the code file and click on the line that assigns the bytea array. Press F9 and you should see a red circle appear to the left of the code line - this is a breakpoint (to remove it, press F9 on that line again). Press F5 to run your application in debug mode and trigger the bit of code that populates your image. Step over the line of code by pressing F10. Right click on the variable btpht and select QuickWatch from the popup menu. You should see btpht in the Expression. To see the value, either expand the variable in the listview below or type btpht.Length in the expression and click Reevaluate.
|
|
|
|
|
please, my english is not good,
look at here
int c = ds.Tables["client"].Rows.Count;
if (c > 0)
{
Byte[] btpht = new Byte[0];
btpht = (Byte[])(ds.Tables["client"].Rows[c - 1]["photo"]);
MemoryStream phtosssss = new MemoryStream(btpht);
pictureBox1.Image = Image.FromStream(phtosssss);
try to bring correction please i have tried but, no error message with the following code , but no picture posted in my picture box
int c = ds.Tables["client"].Rows.Count;
if (c > 0)
{
Byte[] btpht = new Byte[0];
btpht = (Byte[])(ds.Tables["client"].Rows[c - 1]["photo"]);
MemoryStream phtosssss = new MemoryStream(btpht.Length);
pictureBox1.Image = Image.FromStream(phtosssss);
|
|
|
|
|
MINDONGO wrote: MemoryStream phtosssss = new MemoryStream(btpht.Length); No. You should have left this as
MemoryStream phtosssss = new MemoryStream(btpht); All we want is for you to tell us what the Length is. I told you exactly which buttons to press to debug your application. You should have followed those exactly.
|
|
|
|
|
this is the message "Quote: parameter is not valid "
about the length, i created my data base in ACESS, and the type was OLE OBJET, no length specified in case of in access
|
|
|
|
|
Are you even reading my replies? Okay, the simple answer is, you aren't populating the byte array which is why the image is not being displayed. The reason you aren't populating it is because the type is an OLE Object. Basically, this could contain any type of OLE data, so you need to determine what the image was originally stored as and then manually parse the OLE object. Given your inability to follow simple instructions on debugging an application, I would suggest that doing this task will be well beyond you.
If it's meant to be an image format, then store it as an IMAGE datatype in the database and your code should then work.
|
|
|
|
|
by doing what you have told me, i found [0] or zero as the value of btpht.length
modified 1-Apr-14 11:11am.
|
|
|
|
|
MINDONGO wrote: and i have used OLE object in my image data
Since you don't seem to be willing to do anything to help us assist you, I've had to engage me psychic debugging powers, which leads me to the following conclusion:
Your database field doesn't contain a raw stream of image bytes. Instead, it contains an OLE wrapper object[^], which the Image.FromStream method cannot understand. If you can't change how the images are stored in the database, then you'll need to find some code to remove that wrapper to get the raw image bytes back. There's a good example here[^].
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
for the time beeing, i found zero, as btpth.length
|
|
|
|
|
for the moment, the current value btpht as {byte [8]}
|
|
|
|
|
Jquery Easy UI DataGrid not show after publish to IIS using c# MVC 5. How to solve.
My code is ,
$(document).ready(function () {
var urlStr = '@Url.Content("~/Admin/UserView")';
$('#tt').datagrid({
url: urlStr,
striped: true,
singleSelect: true,
columns: [[
{ field: 'USER_ID', title: 'User ID', width: 150 },
{ field: 'USER_NAME', title: 'User Name', width: 200, align: 'left' },
{
field: 'Action', title: 'Action', width: 100,
formatter: function (value, row, index) {
console.log(row);
return 'Select';
}
}
]],
onClickRow: function (idx, data) {
console.log(data);
}
});
|
|
|
|
|
That's JavaScript. This is the C# forum.
|
|
|
|