|
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[^].
|
|
|
|
|
it typically is (a lot) faster. When you have:
string[] lines=...;
string s="";
foreach(string line in lines) s+=line;
each iteration of the for loop will create a new string object and copy all data so far into it.
OTOH
string[] lines=...;
StringBuilder sb=new StringBuilder();
foreach(string line in lines) sb.Append(line);
string s=sb.ToString();
will use only two objects (sb and s), and sb.Append will copy the new data, not all the data, provided the internal buffer has sufficient capacity. The StringBuilder's capacity by default starts out at 16 characters, and doubles when necessary.
You can avoid all unnecessary capacity enlargements and data copies by providing an appropriate initiaal caapacity, so the best approach could be:
string[] lines=...;
StringBuilder sb=new StringBuilder(1000);
foreach(string line in lines) sb.Append(line);
string s=sb.ToString();
which starts out at an SB with room for 1000 characters (which would grow if required, just as before).
FYI: it does not make sense to use StringBuilder for concatenating string literals, as the compiler does that for you automaticaally. So
string s="aaaa"+"bbbbbbbbbbbb"+"ccccc";
only takes one object and one assignment.
ADDED
.NET has some methods that also help in improving string concatenation performance, without any hassle.
string.Join() is a good example.
/ADDED
|
|
|
|
|
To summarize what Luc is saying:
"myString += myItem.ToString()" will create a new string object every time it is used. This means that if you called this in a loop that executed 500 times, you would be creating/trashing and object 499 times!
Think of it this way: The StringBuilder optimizes the creation of large string objects.
The mind is like a parachute. It doesn’t work unless it’s open.
|
|
|
|
|
First off you would never use:
myStringBuilder.Append(myItem.ToString())
Instead use
myStringBuilder.Append(myItem)
This becomes the reason becomes more obvious once you start using AppendFormat:
mStringBuilder.Append("The current date is: {0:MM/dd/yyyy} and the time is: {0:HH:mm}", DateTime.Now);
I use string builder out of habit, rarely using string concatenation. The general rule of thumb is if you have a loop use string builder or if you are building a large string use string builder.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: becomes more obvious once you start using AppendFormat:
It would be more obvious if you used AppendFormat rather than Append
I know the language. I've read a book. - _Madmatt
|
|
|
|