|
how to hide MaximizeBox ?
|
|
|
|
|
Hi,
Form.MaximizeBox=false; almost hides it. Chosing another FormBorderStyle may hide it completely (as well as other parts of the title bar).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
ERROR: An object reference is required for the nonstatic field, method, or property 'System.Windows.Forms.Form.MaximizeBox.get'
|
|
|
|
|
I hope that was a joke - if so, it's not bad
But otherwise..
|
|
|
|
|
hi...
i am saving images in a DB
when i try to open them from the database i have an error
the code:
SqlConnection con1 = new SqlConnection("DATA SOURCE = MAX_TOSHIBA ;Initial Catalog= nodule ; Integrated security = True");
SqlDataAdapter adp1 = new SqlDataAdapter();
SqlCommand com1 = new SqlCommand("SELECT the_pic FROM pic where pic_id='" + chos_pic_id.ToString() + "' and pic_no='" + chos_pic_no.ToString() + "'",con1);
adp1.SelectCommand = com1;
DataTable t__1 = new DataTable();
adp1.Fill(t__1);
byte[] by_ = (byte[])t__1.Rows[0][0];
FileStream FS1 = new FileStream("image.jpg", FileMode.Create);
FS1.Write(by_, 0, by_.Length);
FS1.Flush();
FS1.Close();
pictureBox1.Image = Image.FromFile("image.jpg");
the error appear in the last line saying "out of memory"
thanks in advance
|
|
|
|
|
Hi,
some comments:
1. you are not running out of memory: GDI/GDI+ and .NET generate an "Out-of-Memory" condition when the data is not a valid image.
2. the problem can equally well be in the piece of code that puts the image in the database; you really should compare those two snippets for almost identity.
3. I suggest you log your SQL commands, and the length of the byte arrays
4. you don't need to create an image file to get it from database to PictureBox; a MemoryStream and Image.FromStream() should suffice.
5. Flush and Close does not make much sense, since Close implies a Flush; Flush is useful sometimes when you do not want to close right away.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
hi, thank you for your reply..
i tryed the memorystream ,and i did not work ,it give me the same error !!
the intresting thing i found that the byte numbers it give the error after is 13!! i realy dont know why
i have tryed many images but the same error with the same number 13!!
any way you wanted me to check the input method, i do not find any thing in it , here it is
byte[] data = null;
FileInfo fInfo = new FileInfo(sPath);
long numBytes = fInfo.Length;
MessageBox.Show(numBytes.ToString());
FileStream fStream = new FileStream(sPath, FileMode.Open,FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
data = br.ReadBytes((int)numBytes);
thank you verey much for your time and effort
|
|
|
|
|
Hi,
there is no need for you to show us how a MessageBox.Show statement looks like.
What YOU should do is compare all the different length/size informations you have, and make sure they are all the same, the first to deviate will point you at the (first) problem. Here are all the lengths:
- the file size as shown by Windows Explorer
- the byte[] length when you have read it in in the code that will put it in the database
- the database tools you use should allow you to investigate the size of a specific record and field
- the byte[] length when you get it back out of the database
If all the above are the same, chances are good your last byte[] really contains an image, and you will be able to convert.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
all the images that i load have 13 bytes (where i use the above code)
i do not know how to check the no. of bytes in the (sql 2005)
thanks
|
|
|
|
|
A_A wrote: all the images that i load have 13 bytes
which is clearly wrong. How many image files do you own that small?
Probably none.
A_A wrote: i do not know how to check the no. of bytes in the (sql 2005)
Neither do I, I know how to use PhpMyAdmin to watch fields and field sizes on MySQL tables, I don't have SQL Server where I am right now.
Suggestions:
-dump those 13 bytes in hex, fat chance they form an ASCII string because you called ToString() somewhere, possibly implicitly.
-check your code, try to figure out whether save-to-DB or load-from-DB are the culprit.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
finally, i figer it out
i have to use a code similar to this
main idea is to write the type when we insert the image as "SqlDbType.Image"
SqlConnection con = new SqlConnection("DATA SOURCE = MAX_TOSHIBA;Initial Catalog=nodule; Integrated security = true");
string sql = "INSERT INTO pic (pic_id,patient,id,the_pic,pic_no) values ('" + j + "','" + txt_patient_name.Text + "','" + 0 + "', @a,'" + 0 + "')";
SqlCommand cmd = new SqlCommand();
SqlParameter sp = new SqlParameter("@a", SqlDbType.Image);
sp.Value = by_img;
cmd.Parameters.Add(sp);
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
|
|
|
|
|
Hi,
I made a view from a few tables. I then imported that view into my Entity Data Model. The EDM assigned Entity Key = true to a column in the view that is not a primary key (the column is not a primary key in the view, and it is not a primary key in the table the view gets it from).
Why does the EDM do this? It assigned Entity Key = true to a value that IS an actual primary key (in the table my view looks at) and also to a value that ISN'T a primary key. I can't figure this out. Can anyone help me out?
TIA
PS -- I apologize if this is not the right forum, but since in the EDM I am dealing with C# code, I thought I'd post it here.
|
|
|
|
|
I can only think, this is not a fact, just my thoughts, that it is trying to create a form of compound key. All EntityTypes must have a key and so it is attempting to create a compund key that it thinks will be unique.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks for your reply.
If this is the case, how would I get around it? If I set the column to NOT be a key, I get a mismatch error, suggesting that both fields (EDM and my DB) must be keys.
|
|
|
|
|
I very much regret that, I have no idea. I am only just starting out on the EF Highway, which is why I could still remember the stuff, in my previous post. Give it a month or two and I'll have forgotten that as well.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
Somehow I cannot load any WPF projects into VS 2008. The error I got is "The project type is not supported by this installation."
What is wrong with my VS 2008?
Best,
Jun
|
|
|
|
|
Which version of VS do you have?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
VS 2008 Version 9.0.30729.1 with .NET Framework 3.5 SP 1
Best,
Jun
|
|
|
|
|
Sorry, my fault. I meant version as in Standard, Express, Professional etc.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
OK.
Have you ever been able to load WPF projects? If so and you have recently installed any add-ons, I would try uninstalling them one by one and trying again between uninstalls.
Failing that, if your VS2008 has all the latest updates/service packs I can only suggest a Repair Install, I had a similar problem with an Express version a while ago, and that fixed it. Insert the install DVD and it should offer the Repair facility. If the option appears for a Custom Install, take that and make sure everything is checked.
That is all that I can offer.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Yes. This machine has been reinstalled by an IT person recently. The installation is not clean (half restore and half install).
I'll unstall/install VS 2008 first and see. Hopefully I don't have to redo the entire machine.
Thanks for the help.
Best,
Jun
|
|
|
|
|
Henry,
I have uninstalled all Visual Studio (6.0, 2003/2005/2008) and reinstalled VS 2008 Professional Edition only. The issue remains. After comparison, I do notice some strange things with this Edition:
1) I cannot create a new C# WPF project. The error is the same (project type not supported).
2) The New Project dialog shows the following different WPF types:
"csWPFApplication" (should be "WPF Application")
"csWPFBrowserApplication" (should be "WPF Browser Application"
"csWPFControlLibrary" (should be "WPF Control Library")
"csWPFCustomControl" (should be "WPF Custom Control")
3) All non-WPF types are fine.
By the way, this VS 2008 Edition was from a MSDN subscription.
------------------------
FYI, after I installed VS 2008 SP1 this Edition works like a charm. No WPF project type issue any more. Thanks!
Best,
Jun
|
|
|
|
|
This is very strange. I am at a loss.
Can I suggest that you ask this (exactly as here) in the Microsoft forums here[^].
If you do find a solution, please let us know as it could be useful to others.
I am sorry not to be able to help more. Good Luck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi, have a good day ,
I was wondering , how do you write Database Application With C# ?
I mean what is the your way , what tools do you use and what is your rules ?
--- For me :
1 - All My SqlConnection , DataTable Are in Runtime ( no desing at all )
2 - I write INSERT and update and delete Sql Query Manually , like functions ( even if I have 50 values in INSERT command I wrote them
as paramters
public static void DeletePerson ( string guid )
{
SqlCommand SqlCmd.CommandText ="DELETE FROM persons WHERE guid = @guid";
SqlCmd.Parameters.AddWithValue ("@guid" , guid);
SqlCmd.ExecuteNonQuery();
SqlCmd.Parameters.Clear();
}
3 - I always use paramters .
4 - I always use Transaction ( even for the short one )
5 - I never ever Use Binding Source ( I build one manually )
Like
TxtPerson.Text = clsDataTable.Rows[CurrentRecored]["Name"].ToString();
Insted of
TxtPerson.DataBindings.Add("Text" , bindingsource , "name" );
6 - I never use Identity in my database , I generte the last number
manually
SELECT MAX(PersonID) FROM persons
7 - All my tables recored dependes on GUID ( No Guid = No table at all )
8 - I use SQL Query Analyzer ... I hate VS Server Explorer ...
9 - For Complex Search Query
I used some routin's like :
public string[] SearchUserNames = { "Name" , "Age" };
public string[] SearchDBNames = { "pName" , "pAge"};
stQuery = "SELECT * FROM persons";
int isAnd = 0;
if (CheckName.Checked)
{
stQuery += " WHERE " + SearchDBNames[combobox.SelectedIndex].ToString();
isAnd++;
}
if (CheckAge.Checked)
{
if (isAnd != 0)
{
stQuery += " AND ";
}
else
{
stQuery += " WHERE ";
}
stQuery += SearchDBNames[combobox.SelectedIndex].ToString();
isAnd++;
}
I want to hear from you ... what is yours ?
I am doing right ?
Thank you , for time and for your advice ...
I know nothing , I know nothing ...
|
|
|
|