|
It might be simpler to use Stack<T>:
Stack<TreeNode> history = new Stack<TreeNode>();
bool cancelPush = false;
private void button1_Click(object sender, EventArgs e)
{
if (history.Count > 0)
{
cancelPush = true;
treeView1.SelectedNode = history.Pop();
treeView1.Focus();
}
}
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
if (!cancelPush)
{
history.Push(treeView1.SelectedNode);
}
else
{
cancelPush = false;
}
}
|
|
|
|
|
i have got another problem
i have got a insert statement using which i update my database in the local system it is happening good in the local system...
now coming to application which is put on the webserver now my database is not updating properly i am getting an exception.
i am using server.mappath("dls.mdb");
dls.mdb is my databse name and server.mappath is returning exactly the path on the remote system (like d:/mywebsite/dls.mdb).
please solve me and let me knwo
|
|
|
|
|
Define "not updating properly" Do you get an error ? Can you select data from this db ? Is the file read only ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
the exception which i get is
System.Data.OleDb.OleDbException: Operation must use an updateable query. at System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) at System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) at System.Data.OleDb.OleDbCommand.ExecuteNonQuery() at Details.btnsubmit_Click(Object sender, EventArgs e)
in the webserver
and the file is not read only
|
|
|
|
|
A great way to solve error issues is to google the error message. I found this:
http://support.microsoft.com/default.aspx/kb/830977[^]
In a nutshell:
This problem occurs when a Microsoft Access database file is used as your database source because you must grant write access to both the default worker process identity and the authenticated user.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thanks a lot dude
i fighting from yesterday
thanks a lot
bye
|
|
|
|
|
our website is being hosted by some other people sir
and now i have changed write permission and i updated on the webserver
still the same problem is coming
do i need to publish my site once again and update all of them or
only the databasse file has to replaced sir
thanking u bye
|
|
|
|
|
Hi to everyone!
I need to get the autonumeric field assigned to a new record, because I want to use it on a different table.
ExecuteNonQuery retrieves the number of affected rows. But how can I get a dataset result of the affected rows, as the one using an ExecuteQuery command?
Thanks for everyones time!
daniel sovino
|
|
|
|
|
You can ask he database for the last created key. Depending on what database you are using, you use different functions:
MySQL: select last_insert_id()
MS SQL: select scope_identity()
Access: select @@identity
---
Year happy = new Year(2007);
|
|
|
|
|
Question.
If the affected Rows are more than 1 do the above statements return one ID or more?
|
|
|
|
|
It only returns the last id.
---
Year happy = new Year(2007);
|
|
|
|
|
The original question said about rows.
The only way I can think except from triggers is to have a column something like just updated. Then query for those and just before finishing set the columns to false.
|
|
|
|
|
Sarafian wrote: The original question said about rows.
Well, you don't always get what you ask for.
Sarafian wrote: The only way I can think except from triggers is to have a column something like just updated. Then query for those and just before finishing set the columns to false.
An alternative would be to first get the id:s of the records to update, then use them to update the records.
---
Year happy = new Year(2007);
|
|
|
|
|
Ok, but how do I get this done?
I had lots of troubles working with access database and the dataset wizard to store querys (http://forums.microsoft.com/MSDN/showpost.aspx?postid=1121807&siteid=1), so I opted to run my queries with code.
I used one method with the Insert command, and if the result set is higher than 0, I call another method with a Scalar Command, to search for the ID. Then, with the retrieved ID, i call the third method to Insert the record ID on the second table....
The code described below worked well, everyonce in a while (no clue yet why sometimes i'm able to get the ID and sometimes I get 0, probably something going on with the query). So that's why I want a safer way to get this done.
I searched a little bit for "select @@identity" (http://support.microsoft.com/kb/816112), and I found out that it behaves as a Scalar command as well. So in theory, i should just change my query string to get it done.
It doesnt work at all. Does the "select @@identity" statement work only when you handle it on a OleDbDataAdapter.RowUpdated Event?
Thanks for the help!
<br />
<br />
string file = "......";<br />
<br />
private void InsertAudio()<br />
<pre>
<small>
{
OleDbCommand cmd = new OleDbCommand(sql, conexion);
int resultSet;
try
{
conexion.Open();
resultSet = cmd.ExecuteNonQuery();
if (resultSet > 0) SearchIDofCreatedRow();
}
catch (OleDbException ode)
{
MessageBox.Show(ode.ToString(), "Error de Conexion con base de datos");
}
finally {conexion.Close();}
}
</small>
</pre><br />
<br />
<br />
private void SearchIDofCreatedRow()<br />
<pre>
<small>
{
OleDbCommand cmd = new OleDbCommand("SELECT ID FROM audios WHERE file='" + file + "'", conexion);
try
{
conexion.Open();
int ID = Convert.ToInt32(cmd.ExecuteScalar());
AddCategoryList(ID);
}
}
</small>
</pre><br />
<br />
private void AddCategoryList(int ID)<br />
<pre>
<small>
{
}
</small>
</pre> <br />
<br />
daniel sovino
|
|
|
|
|
The @@identity variable is local to the database session, and if you create another connection you get a new database session. You have to get the id using the same database connection that you used to insert the record.
Why do you create a new connection in SearchIDofCreatedRow? When you call it you already have an open connection, pass that along in the call.
---
Year happy = new Year(2007);
|
|
|
|
|
hi all,
I have do a research how can i pass parameter in MouseEventHandler,but i can't get any answer on it.What i am trying to do is :
When double click on certain user control(my own user control) ,then will implement some action,as below:
trending1.MouseDoubleClick += new MouseEventHandler(enLargeChart1);<br />
.....<br />
private void enLargeChart1(object sender, EventArgs e){}
Now,i would like to pass the selected control name (or anything can indicate what is the control) to enLargeChart1() when i double clike on that control.
Can somebody guide me to solve it out?
Thanks in advance
cocoonwls
|
|
|
|
|
the sender parameter indicates which control was clicked,
so you could use ((Button)sender).Name or something similar to identify it.
Luc Pattyn
|
|
|
|
|
Hi, Luc Pattyn
Thank you very much!!!It work for me
cocoonwls
|
|
|
|
|
I Want Append 10000 row data in DataGridView.But,the speed of display is lower.In others windows control (ex. listview,listbox) have BeginUpdate and EndUpdate method.
I want to write a method like BeginUpdate that Prevents the control from drawing until the EndUpdate method is called.
|
|
|
|
|
how to write the method like BeginUpdate.
|
|
|
|
|
What is the easier way to write a program to run a method and while that methods is being performing to run another method. Is this possible to do?
|
|
|
|
|
Eddymvp wrote: Is this possible to do?
Yes. See the Thread class and examples of Thread.Start().
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
hi all,
i ve a small question how is the following problem posible
Hashtable MyTable = new Hashtable();
MyObject myo = new MyObject()
MyTable.Add(1,myo);
How is the following posible
MyTable[1].FunctionFromMyObject();
greetings gigo
|
|
|
|
|
gigo2k6 wrote: i ve a small question how is the following problem posible
Are you asking how a hashtable works?
Or do you mean:
gigo2k6 wrote: How is the following posible
MyTable[1].FunctionFromMyObject();
MyObject mo2=(MyObject)MyTable[1];
mo2.SomeFunction();
BTW, look up generics, so you can avoid the cast back to MyObject.
Marc
Thyme In The CountryPeople are just notoriously impossible. --DavidCrow There's NO excuse for not commenting your code. -- John Simmons / outlaw programmer People who say that they will refactor their code later to make it "good" don't understand refactoring, nor the art and craft of programming. -- Josh Smith
|
|
|
|
|
hi this was not what i want.
but the following works fine
((IP_cam)_Cams[1]).SomeFunction();
|
|
|
|