|
|
|
You are welcome!
|
|
|
|
|
i have bitmap that changes on run time.
each time the bitmap change i need to update the pictureBox that i have on my form.
I cant find a way to change the image on the pictureBox -
Each time i do
pictureBox.Image = myBitmap;
I get error.
What to do ?
|
|
|
|
|
Whats your myBitmap contains.
Use
pictureBox.Image = New System.Drawing.Bitmap("YourBitmapFilename.BMP");
|
|
|
|
|
What error do you get?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Yanshof wrote: I get error.
What to do ?
We aren't mind readers, if you don't tell us what the error message is, the only available advice is: read the error message, look at the file name and line number it mentions, and fix it.
|
|
|
|
|
I change something in the code and i think that the error message was from some other place.
But the Image is not shown on the pictureBox yet - and i dont know what is the reason.
The input of the pictureBox is bitmap that i collect and store on some collection - so there is no actually file that the bitmap is save on.
|
|
|
|
|
when an error occurs, a lot of detailed information is available. At compile-time, an error always has a filename and line number associated with it, and one should look at that particular line. At run-time, managed code throws exceptions and when looking at them, they too reveal a class name, method name and line number, typically sufficient to pinpoint the problem.
finally when code runs without exceptions but does not produce the result one hopes for, there is that thing called debugging. Try single-stepping, try looking at some intermediate values, etc. And when all else fails, you can ask on a forum like this one, however then you need to provide an accurate symptom description and the relevant piece of code so some one can effectively help you.
|
|
|
|
|
Hi, as i titled i really need to compile a vdproj in command line or in c# classes! i googled and i found nothing really related!
THANK YOU
|
|
|
|
|
Take a look at MsBuild.
Best wishes,
Navaneeth
|
|
|
|
|
MS build cant build vdproj, test it!!!!!!
devenv could do this!
|
|
|
|
|
hi
where i should use SqlCommand.Parameters.Add()method and where
SqlCommand.Parameter.AddWithValue()?
is there performance diffrence?
|
|
|
|
|
Hi,
Specially parameters used to pass data to ur query , as inset update delete even select
select *
from t1
where id = 12
this query always returns a fixed result, now going to make it gloabal, i mean change the 12 value to needed value, so u use parameters as:
select *
from t1
where id=@id
now in command line, u must set the parameter, look at this method as a sample:
private DataTable SelectParameter(int idvalue, bool useWithvalue)
{
string constr = "";
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("select * from t1 where id=@id", con);
if (useWithvalue)
{
cmd.Parameters.AddWithValue("@id", idvalue);
}
else
{
SqlParameter p = new SqlParameter("@id", SqlDbType.Int);
p.Value = idvalue;
cmd.Parameters.Add(p);
}
con.Open();
DataTable dt = new DataTable();
dt.Load(cmd.ExecuteReader());
return dt;
}
in cases that u are going to set the value type of parameter u should use add else u could use both of them.
|
|
|
|
|
I hear that AddWithValue is kinda safer, but I rarely use it because of the way I do things.
It's not a performance issue.
|
|
|
|
|
I like .AddWithValue just to save keystrokes, but never noticed any performance difference either way.
|
|
|
|
|
I'm trying to retrieve an application from my database. I have a Data Context in my app called AppSecurityDataDataContext. Here's my query:
{
AppSecurityDataDataContext dc = new AppSecurityDataDataContext();
var app = from a in dc._Applications
where a.ApplicationId = ApplicationID
select a;
}
I'm getting "Could not find an implementation of the query pattern for source type 'System.Data.Linq.Table<AppSecurity._Application>'. 'Select' not found. Are you missing a reference to 'System.Core.dll' or a using directive for 'System.Linq'?"
I have the using statement in my class. This other method works:
public static void AddApplication(Application Application)
{
_Application app = new _Application
{
ApplicationName = Application.ApplicationName
};
_DataContext._Applications.InsertOnSubmit(app);
try
{
_DataContext.SubmitChanges();
}
catch (Exception e)
{
}
}
Anyone see what's wrong here?
Everything makes sense in someone's mind
|
|
|
|
|
Do you have the LINQ dll referenced in your project as well as the proper build target set?
|
|
|
|
|
As I said in my post, I have the using statement in my class.
Everything makes sense in someone's mind
|
|
|
|
|
Because a using statement and required dll's or correct version of dll's are synonymous.
|
|
|
|
|
The problem was that I was using System.Data.Linq, not System.Linq.
Everything makes sense in someone's mind
|
|
|
|
|
OK, so I know StringBuilder offers all sorts of nice features but if I'm only interested in iterating through a number of items and adding them to a string, is there a good reason why successive myStringBuilder.Append(myItem.ToString()) with an eventual myStringBuilder.ToString() would be beneficial as opposed to a simple successive myString += myItem.ToString() ?
|
|
|
|
|
It's said to be faster. Appending to a string in a loop would preferably be done by a StringBuilder , while a normal concatenation might be more readable when using the += option.
I are Troll
|
|
|
|
|
The real difference is in allocations... a += b is really shorthand for a = a + b , which works by creating a new string of the proper length, copying a and b to it, and assigning that value to a .
If you do that a thousand times, you're allocating a thousand strings in memory, each one a bit longer than the previous.
The StringBuilder, if I remember correctly, basically works like a variable-length array. If it starts with a length of 100, then you can just keep appending text in-place until it reaches a length of 100, at which point it'll reallocate itself to a length of, say, 200. Instead of doing a thousand allocations, you might only be doing a hundred or less. If you already know something about how many strings you'll be adding, or their average length, you can tweak the StringBuilder in its constructor to reduce this further.
It's a minor improvement if you're only adding a few things, but it really makes a huge difference in a long loop, or one that you repeat often.
|
|
|
|
|
Efficiency! But it depends on the number of your items.
If you have a small number of items use normal string concatenation (+=).
If you have a large number of items and many concatenations (i.e. in loop) than StringBuilder should be the choice.
Read more here[^].
|
|
|
|