|
CLUE:
UPDATE mytable SET field1=@F1,field2=@F2 WHERE field3=@F3
cmd.AddWithValue("@F1", "111");
cmd.AddWithValue("@F2", "222");
...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi
I am looking for a way to find an item in a list box by its index number, then copy it to a variable any ideas.
Thanks
|
|
|
|
|
Have you tried using it's index number at all?
ListBox lb = new ListBox();
lb.Items.Add("Hello");
lb.Items.Add("Goodbye");
string s = lb.Items[1] as string;
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I think you meant lb.Items[0] .
/ravi
|
|
|
|
|
Maybe Griff did mean [1] for "Goodbye", as in "Goodbye. Now go look things up in MSDN and/or learn to use Google and stop bothering everyone with elementary questions like that."
|
|
|
|
|
Heh. But what's obvious to some may not be obvious to others. Isn't that what learning's all about?
/ravi
|
|
|
|
|
Sure, however making some effort yourself can be very rewarding and typically yields more insight. The OP has gotten answers already he clearly is not following up by reading the doc at all.
|
|
|
|
|
And there was me trying to be subtle...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Too much so, I'm afraid. I felt the need to clarify a little.
|
|
|
|
|
I don't often get told I'm too subtle! Normally it's quite the reverse. It'll be a pipe and carpet slippers next, I'm afraid...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
OriginalGriff wrote: It'll be a pipe and carpet slippers next
Now you've lost me, you really need to start formulating more clearly.
|
|
|
|
|
I have some callback method that set on my queue some bitmap.
This callback is called every 3 millisecond.
What i mean is that my queue will be fill up with a new bitmap every 60 Millisecond.
I trying to get the first picture ( this is queue ... ) and show it on pictureBox - but i get some "external error e0434352" and i don't understand why and what this exception error mean.
This external exception appear on the line that i update the image ( this.pictureBox1.Image = Image.FromHbitmap( img ) )
Please someone can help me ? - i really don't have any idea what the problem can be and how to solve it.
private void CallBack( object sender, IntPtr e )
{
lock( IncomingBmp )
{
IncomingBmp.Enqueue ( e );
if( IncomingBmp.Count > 10)
{
UpdateBitmap( IncomingBmp.Dequeue() );
}
}
}
private void UpdateBitmap( IntPtr img )
{
if( this.pictureBox1.InvokeRequired == true )
{
UpdateBitmapCallback p = new UpdateBitmapCallback( UpdateBitmap );
this.Invoke( p, img );
}
else
{
Image oldImage = this.pictureBox1.Image;
this.pictureBox1.Image = Image.FromHbitmap( img );
if( oldImage != null )
oldImage.Dispose();
}
}
|
|
|
|
|
So your callback is getting a pointer/handle to some data, and later on you try and transform that pointer/handle into a managed object. Who is to say the pointer/handle is still valid (pointing at valid data) at the moment you try and use it?
IMO what you should do is have the callback get the data and turn it into an image right away. Then you could queue the image itself for later use.
Furthermore the MSDN doc on FromHBitmap says:
"The FromHbitmap method makes a copy of the GDI bitmap; so you can release the incoming GDI bitmap using the GDI DeleteObject method immediately after creating the new Image."
Are you taking care of that?
|
|
|
|
|
hello,
i used to write c# programs but i didn't write for more than 2 years and you can say i forgot every thing about c#.
and now i am back to c# and programming in general so i am trying to write a simple c# program and i am stuck in the following:
-1- i have inserted a Button on the main form, this button is supposed to call another form when it is clicked:
private void Button1_Click(object sender, EventArgs e)
{
?????????
}
what i am suppose to do to call the other form.
-2- is there an example showing how to deal with office access database. how to insert new items and to call them from the database.
i am using Visual studio 2008 and office 2007.
thank you for your help.
|
|
|
|
|
Did you tried MSDN? I am 100% sure you will get examples for these things there.
|
|
|
|
|
thank you. i will start using it.
|
|
|
|
|
MyNewForm mnf = new MyNewForm();
mnf.ShowDialog();
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
thanks.
|
|
|
|
|
Hey friends,
I hav a small question. I'm starting to develop a C# Windows application from scratch. The application will need a datasource. Previously I've always developed using MS SQL Server but for this app I don't want to have 'having an sql server instance' as a requirement.
I want a single file database or something, and is possible with LINQ support. What kind of datasource are recommended?
|
|
|
|
|
How much data does your application uses? If it not much, you can use XML or Access. If it is large amount of data, use a real database.
|
|
|
|
|
It's hard t say what would work best for you since you gave no real requirements other than single file and not SQLServer.
Using an Access (Jet) database is one possibility. The problems with Access are its size limitation and that it's a pain-in-the-butt to create a new Access database programatically. If you don't have to worry about those things, then Access (Jet) might work just fine.
You might also consider using SQLite, although it also has limitations and I'm not sure if it supports Linq.
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
try db4o.
It's an object database, meaning you store the objects directly. It's fast to
develop and easy to use. But only for local stuff. I wouldn't use it as a DB server.
It's free under GPL. The learning curve it's a breeze.
The new version suports LINQ too.
Here is a direct link to their tutorial.
I bug
|
|
|
|
|
static string DecodeUnicode(string s)
{
StringBuilder sb=new StringBuilder();
while (s.Length!=0)
{
sb.Append((char)int.Parse(s.Substring(2, 4), NumberStyles.HexNumber));
s=s.Substring(6);
}
return sb.ToString();
}
string s="\\u092A\\u094B\\u0937\\u093E\\u0939\\u093E\\u0930";
s=DecodeUnicode(s);
I am using above code to remove "\\" into "\". But if we add some text in this string its gives error.
e.g.:string s="\\u092A\\u094B\\u0937\\u093E\\u0939\\u093E\\u0930 abc";
error msg shows: Input string doesn't match.
i think this issue occur due to, i divide substring(2,4)
please guide me.
thanx
|
|
|
|
|
if your input string does not consist only of \\uddd sequences (where each d is a digit), then you need to search for such substrings and replace them one by one by the character they represent.
|
|
|
|
|
Well, first... If you type this:
string s="\\u092A\\u094B\\u0937\\u093E\\u0939\\u093E\\u0930";
Then the compiler is already converting the double-backslashes to single-backslashes... But assuming you actually have the doubles in the string...
Try just using string.Replace() ...
s = s.Replace(@"\\",@"\")
The @ sign before the first quote tells C# to ignore the escape characters (Including things like newlines and tabs)... You could also write s.Replace("\\\\","\\");
|
|
|
|