|
Not exactly the same code, not, but it does mirror what I have. I shall have to dig further. Thanks for checking. If I figure out more details, I'll let you know.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
OK, you're right. My problem, as it turns out, is that one of the properties I'm trying to set (which just happens to be on my base class, thus the origin of this question) has a PRIVATE set accessor (the get is public), and this is throwing the reflection framework off. Using the BindingFlags enumeration to tell GetProperties that I want NonPublic members doesn't help, since the property itself is public. Crud...
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
Got it. I have to use PropertyInfo.GetSetAccessor(true). Worked like a charm.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
well i'd declare _HasFur and _NumberOfLegs as protected rather than private..
life is study!!!
|
|
|
|
|
It was just a quick mock up.
Kyosa Jamie Nordmeyer - Taekwondo Yi (2nd) Dan
Portland, Oregon, USA www.defaultn.com
|
|
|
|
|
Hi,
Plz help me!!!
I have a DataGridView with data, i need pick data from 1st column upon mouse click,
But itz wierd..When I click on 1st column data of any Row, sometimes event gets fired sometimes never.
For eg: the following message pops up when i click on any column otherthan 1st
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
MessageBox.Show("Header Index " + e.ColumnIndex);
}
also dataGridView1_CellMouseClick the same...
Can any one gives me clue.
Your help is highly appreciated
Thanks in advance
Monika.
|
|
|
|
|
|
ok. I have a program that is so far only supposed to initialize DirectX. In it there are references and one file: Form1.cs. I started it as an empty project, but when i run it the command prompt shows up.
Why is my application showing the command prompt?
Is it somewhere in my coding?
Thanks.
It's probably pretty obvious...
|
|
|
|
|
It has nothing to do with your code, this is an option located in the Properties for your project under Application > Output type.
Internet - the worlds biggest dictionary
|
|
|
|
|
|
As per a previous thread I have an app which receives events from a COM object. Those events come in on a different thread than my app, so I'm using Control.BeginInvoke() to correct the problem.
BeginInvoke() asynchronously queues the event for handling by my app. The problem is, I want to log the actual time the event was received, not when my handler was finally called to process the queued event.
So I'm calling a delegate which takes one more argument than my handler, and I'm passing in the time, like this:
private delegate void _OnSoundVolumeChangedEvent(DateTime time, int newVolume);
private void itunes_OnSoundVolumeChangedEvent(int newVolume)
{
if (InvokeRequired)
{
BeginInvoke(new _OnSoundVolumeChangedEvent(_OnSoundVolumeChangedEventInvoked), new object[] { DateTime.Now, newVolume });
}
else
{
Debug.Assert("Whoa! Expected this event to require Invoking!")
}
}
private void _OnSoundVolumeChangedEventInvoked(Datetime time, int newVolume)
{
// Do my work
}
However, I'm now curious: if InvokeRequired was true, is it safe to call DateTime.Now? I've already established that it was not safe to pass any of my other form data, since that data belonged to the form thread, and not the calling thread. However, is there any problem calling system methods like DateTime.Now, from the calling thread?
|
|
|
|
|
The one thing you MUST avoid is sharing Controls: a thread that did not create a Control
should not touch it (except for the three or four members that are thread-safe,
including InvokeRequired itself).
In general, having multiple threads working on the same data requires caution (which
often means locks).
The framework classes mostly follow the rule "Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe."
DateTime has that same sentence in the doc; and DateTime.Now is static, so no problem here.
Luc Pattyn
|
|
|
|
|
I've also decided to pass the Control.InvokeRequired value itself to the delegate, so I can log whether I really needed to use BeginInvoke (which I'm going to use anyway). Since that is a form-level value, sort of - is it safe to pass it?
|
|
|
|
|
I already told you InvokeRequired is available to all threads.
The opposite would make it absolutely useless, it then would always be false !
Luc Pattyn
|
|
|
|
|
Hello,
I am writing a c# program that uses dataGridView to view my database tables (Access), which are selected by a comboBox.
I have a problem with the INSERT INTO statements. The first table (has the comboBox index 0) insertion is ok but the next two tables when the insertion is made gives me an error "syntax error in INSERT INTO statement", although its the exact same as the first table insert statement!
I can't figure whats wrong, if you can help me with it I'd appreciate it.
Thank you.
-- modified at 20:29 Friday 26th January, 2007
Regards,
Butterfly
|
|
|
|
|
Butterfly_h wrote: I can't figure whats wrong
Neither can we unless we see some code
Butterfly_h wrote: if you can help me with it I'd appreciate it
Just show us a snippet of what's going wrong and we'll try and help you.
I have no idea what I just said. But my intentions were sincere.
Poore Design
|
|
|
|
|
Please if you can take a look at my code.
Thanks.
Regards,
Butterfly
|
|
|
|
|
What is the text of the statements ? How are they generated ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
<br />
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)<br />
{<br />
switch (comboBox1.SelectedIndex)<br />
{<br />
case 0:<br />
{<br />
customerAdd();<br />
break;<br />
}<br />
case 1:<br />
{<br />
materialAdd();<br />
break;<br />
}<br />
case 2:<br />
{<br />
accessoryAdd();<br />
break;<br />
}<br />
}<br />
}<br />
<br />
private void accessoryAdd()<br />
{<br />
int rowCount = dataGridView1.SelectedRows.Count;<br />
int newRowPosition = dataGridView1.CurrentRow.Index;<br />
string x, y;<br />
<br />
string path1 = Application.StartupPath;<br />
path1 = string.Concat(path1, "\\Data\\");<br />
string myStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path1 + "materialCopy.mdb";<br />
<br />
OleDbConnection myConn = new OleDbConnection(myStr);<br />
<br />
try<br />
{<br />
myConn.Open();<br />
}<br />
catch (OleDbException ex)<br />
{<br />
MessageBox.Show("Error in connection ..." + ex.Message);<br />
}<br />
OleDbCommand myCmnd = new OleDbCommand();<br />
OleDbDataAdapter myAdapter = new OleDbDataAdapter();<br />
DataSet ds = new DataSet();<br />
<br />
x = dataGridView1.Rows[newRowPosition].Cells[0].Value.ToString();<br />
y = dataGridView1.Rows[newRowPosition].Cells[1].Value.ToString();<br />
<br />
myCmnd = new OleDbCommand("INSERT INTO Accessories (accessory-type, accessory-price)" + "VALUES('" + x + "','" + y + "')", myConn);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Accessories");<br />
<br />
myCmnd = new OleDbCommand("SELECT * FROM Accessories", myConn);<br />
myAdapter = new OleDbDataAdapter(myCmnd);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Accessories");<br />
myAdapter.Update(ds, "Accessories");<br />
<br />
myConn.Close();<br />
accessoriesDbOn();<br />
}<br />
<br />
private void customerAdd()<br />
{<br />
int rowCount = dataGridView1.SelectedRows.Count;<br />
int newRowPosition = dataGridView1.CurrentRow.Index;<br />
string n, y, z;<br />
<br />
string path1 = Application.StartupPath;<br />
path1 = string.Concat(path1, "\\Data\\");<br />
string myStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + path1 + "materialCopy.mdb";<br />
<br />
OleDbConnection myConn = new OleDbConnection(myStr);<br />
<br />
try<br />
{<br />
myConn.Open();<br />
}<br />
catch (OleDbException ex)<br />
{<br />
MessageBox.Show("Error in connection ..." + ex.Message);<br />
}<br />
OleDbCommand myCmnd = new OleDbCommand();<br />
OleDbDataAdapter myAdapter = new OleDbDataAdapter();<br />
DataSet ds = new DataSet();<br />
<br />
n = dataGridView1.Rows[newRowPosition].Cells[1].Value.ToString();<br />
z = dataGridView1.Rows[newRowPosition].Cells[2].Value.ToString();<br />
y = dataGridView1.Rows[newRowPosition].Cells[3].Value.ToString();<br />
<br />
myCmnd = new OleDbCommand("INSERT INTO Customer (name, mobile, phone)" + "VALUES('" + n + "','" + z + "','" + y + "')", myConn);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Customer");<br />
<br />
myCmnd = new OleDbCommand("SELECT * FROM Customer", myConn);<br />
myAdapter = new OleDbDataAdapter(myCmnd);<br />
myAdapter.SelectCommand = myCmnd;<br />
ds = new DataSet();<br />
ds.Clear();<br />
myAdapter.Fill(ds, "Customer");<br />
myAdapter.Update(ds, "Customer");<br />
<br />
myConn.Close();<br />
customerDbOn();<br />
}<br />
<br />
This is the code for the addition (insert new row into a table) that I use. The Material table shows no error but both Customer and Accessories tables give me the error I mentioned before (Syntax error in "INSERT INTO").
Regards,
Butterfly
|
|
|
|
|
You might log the offending INSERT INTO commands and see what is wrong.
Are spaces relevant ?
Luc Pattyn
|
|
|
|
|
I tried doing so but the same error occurs!
Regards,
Butterfly
|
|
|
|
|
Butterfly_h wrote: ("INSERT INTO Accessories (accessory-type, accessory-price)" + "VALUES('" + x + "','" + y + "')",
try using the escape char with your single quotes... for example "VALUES(\'" + x + "\', \'" + y + \'")
are x, y and the relevant db columns of the same data type?
|
|
|
|
|
yes they are.
If you can go through the code I have three tables each has the same insert statement but it only works with the Material table.
I'll try your suggestion and tell you what happens.
Regards,
Butterfly
|
|
|
|
|
I once more suggest you list the three actual INSERT lines (on 3 consecutive lines!),
and I am confident you will spot the problem.
Luc Pattyn
|
|
|
|
|
I tried it and it still not working!
Please if anyone figures it out to tell me.
Regards,
Butterfly
|
|
|
|
|