|
Luc Pattyn wrote: a major chess tournament is about to start.
Good luck!
Luc Pattyn wrote: I can't find the hidden message I'm sure you must have hidden in there
No, no - I wouldn't do that!
Luc Pattyn wrote: those few characters on each line are the most useful data in there
I'm not too sure about that - I would agree that they are the most accurate data in many peoples software, though!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
The badgers fly south in august. Peppermint discus tower emblem.
|
|
|
|
|
Guys, I thank you for the help thus far.
I think I have resolved the problem. The problem seems to have been in the connection state. I added a bunch of checks to see fi the connection was open or closed and then opening, or closing it depending on the state and that seems to have resolved the issue. Below is a work in progress, I am still trying to clean this up a bit more by passing parameters to my SQL statements. Thanks again for the help guys.
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
int currentRow = e.RowIndex;
int rowint = 0;
try
{
string taskstring = dataGridView1[0, currentRow].Value.ToString();
rowint = int.Parse(taskstring);
if (dataGridView1.Columns[e.ColumnIndex] == deleteButton && currentRow >= 0)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
else
{
conn.Open();
OleDbCommand sqlDelete = new OleDbCommand("DELETE FROM tblTasks where TaskCode = @rowint", conn);
OleDbParameter param = new OleDbParameter();
param.ParameterName = "@rowint";
param.Value = rowint;
sqlDelete.Parameters.Add(param);
sqlDelete.ExecuteNonQuery();
getData();
}
}
if (dataGridView1.Columns[e.ColumnIndex] == editButton && currentRow >= 0)
{
if (conn.State == ConnectionState.Open)
{
conn.Close();
}
else
{
conn.Open();
string updatestring = "Select TaskCode, TaskName, TaskDescription FROM tblTasks WHERE TaskCode = " + rowint + "";
string taskname = dataGridView1[dataGridView1.Columns["TaskName"].Index, currentRow].Value.ToString();
string description = dataGridView1[dataGridView1.Columns["TaskDescription"].Index, currentRow].Value.ToString();
OleDbDataAdapter da = new OleDbDataAdapter(updatestring, conn);
OleDbCommandBuilder cmdb = new OleDbCommandBuilder(da);
da.Update(dt);
string update = "UPDATE tblTasks SET TaskName = '" + taskname + "', TaskDescription = '" + description + "' WHERE TaskCode = " + rowint + "";
da.UpdateCommand = conn.CreateCommand();
da.UpdateCommand.CommandText = update;
da.UpdateCommand.ExecuteNonQuery();
getData();
}
}
else
{
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
conn.Close();
}
}
I am hoping to publish this project when I am done and then if all is working then I want to see if I can port it to ASP.NET, coding a web page instead, making it easier for everybody to access instead of the having install it on each machine individualy.
Thanks again guys. You realy made me think and re-think and think again!
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Using parameters is a very good idea - but there is a nicer way:
OleDbCommand sqlDelete = new OleDbCommand("DELETE FROM tblTasks where TaskCode = @rowint", conn);
OleDbParameter param = new OleDbParameter();
param.ParameterName = "@rowint";
param.Value = rowint;
sqlDelete.Parameters.Add(param);
Becomes:
OleDbCommand sqlDelete = new OleDbCommand("DELETE FROM tblTasks where TaskCode = @rowint", conn);
sqlDelete.Parameters.AddWithValue("@rowint", rowint);
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks Griff. How would I write one for multiple columns UPDATE? Been searching and most posts only shows 1 parameter being passed at a time
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
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
|
|
|
|