|
Hi Sean,
If all you want the the count then just change your SQL to
SELECT COUNT(*) FROM Mounts WHERE Group_Number = 1
HTH
Web design and hosting
http://www.kayess.com.au
|
|
|
|
|
Thanks for the response! I tried it and it still seems to be returning 0.
Even if I change the query to select everything:
SELECT * FROM Mounts
It still seems to say that the number of rows affected is 0.
I'll just use this till I decide to figure out whats wrong:
OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM Groups", conn);
conn.Open();
OleDbDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
int count = reader[0];
}
conn.Close();
It works at least
|
|
|
|
|
Since your query changed no rows, the rows affected will be 0...
You can't get a rowcount from a datareader until you read to the end.
The result of your query IS a single record containing a single column whose value is the number of records matching the query. I wouldn't know how else to get it than he way you settled on...
We need to graduate from the ridiculous notion that greed is some kind of elixir for capitalism - it's the downfall of capitalism. Self-interest, maybe, but self-interest run amok does not serve anyone. The core value of conscious capitalism is enlightened self-interest.
Patricia Aburdene
Bulls make money, bears make money, pigs get slaughtered.
Jim Cramer
|
|
|
|
|
Thats what I thought too, but for some reason I thought I had done it with ExecuteNonQuery(); before... Guess not
Thanks for the help.
|
|
|
|
|
Try this:
<code>
static void Main(string[] args)
{
string dataPath = @"C:\Documents and Settings\Administrator\Desktop\Transimount_Data.MDB";
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0; data source=" + dataPath);
OleDbCommand cmd = new OleDbCommand("SELECT COUNT(*) FROM Mounts WHERE Group_Number = 1", conn);
conn.Open();
int count = cmd.ExecuteScalar();
conn.Close();
Console.WriteLine(count);
}
</code>
Kuira
|
|
|
|
|
Yeah that works Thanks!
|
|
|
|
|
Hi All,
I have an app which opens three other apps as the user requires them.
What I would like to do is, if the app (process) is already running,
give it the focus rather than open another instance of it.
Can maybe someone point me in the right direction.
TIA
Web design and hosting
http://www.kayess.com.au
|
|
|
|
|
check out the following link.
http://www.c-sharpcorner.com/FAQ/Create1InstanceAppSC.asp
it show how to give focus to application if it is already running and uses its id to compare, in your case you can search process by name.
Shajeel
|
|
|
|
|
Thanks a lot Shajeel. It worked a treat
Web design and hosting
http://www.kayess.com.au
|
|
|
|
|
Hello,
I want to allow the user to specify if my application is automatically started when the OS boots. I understand that I need to add an entry to the Run registry key to make this happen but I also want to allow the app to auto-start in the system tray. To do this I have a command line and I use this command to set the key in the registry
key.SetValue("MyApp", Application.ExecutablePath + " /tray");
but this doesn't put any speech marks around the executable path.
How can I make it so that the value in the registry has the quote marks around it so that the /tray part is a command line param and not part of the path itself?
I want the registry key to be something like "C:\Program Files\MyApp\MyApp.exe" /tray.
How can I do this?
Thanks,
|
|
|
|
|
I'm pretty sure \" is the proper escape sequence for ".
I think you could say:
key.SetValue("MyApp", "\""+Application.ExecutablePath + "\" /tray");
But I don't know how the registry would like it.
-Daniel
|
|
|
|
|
Works perfectly, thanks Daniel.
|
|
|
|
|
I need to clip the cursor to a specific area in my application which I am able to do so. But the problem is when I ALT+TAB to some other window still the cursor is clipped restricting my movement. I would like to know how to clip the cursor only to my application thread without using API's
BK
|
|
|
|
|
You could probably, before you set the clip area store the existing one in a local variable. When you app/form loses focus it restores the original clip area then when it receives focus again it resets the clip area.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
i am working on my project which is related to transfer video clips i.e. video files from pc to mobile devies over session initiation protocol (sip)in the context of sms i.e. without using GPRS and needs help on it. if any one have any knowledge about this please guide me.
Thanks
Muhammad Kashif
|
|
|
|
|
I've tried asking this on microsoft.public.dotnet.languages.csharp, but I am getting no response. Maybe I'm getting lost in the traffic. So, let's try it here.
Dev env: VS 2005 C# Express, .Net Framework 2.0
I am trying to programmatically select an item in a listbox on a web page. The first thing I do is go through and de-select any selected items. The OuterHtml field of a selected element in the listbox looks something like this:
Default item
I want to simply remove the the term 'selected' this way:
elt.OuterHtml = elt.OuterHtml.Replace("selected","");
This results in OuterHtml being set to:
Notice: 1) the 'selected' term is untouched, 2) the visible text has been removed.
After the assignment I can see in the debugger that one of the members of the HtmlElement object (OffsetParent, I think) has a string indicating some kind of COM Interop services exception.
The MSDN documentation at
http://tinyurl.com/edbln
does contain this warning:
"If you assign a new value to OuterHtml, the current element reference will become invalid; it will not reflect the name, properties and child content of the HTML you have just assigned."
but I don't really understand what that means.
Is it possible to change the HTML in a web page? Am I going about it the wrong way? Is there some kind of initialization or setup call I am supposed to make? Is it just a bug in .NET 2.0?
|
|
|
|
|
Perhaps you should start by mentioning what you are doing? Are you changing the page in a browser from another program? Do you have a browser component in your program that shows the page you are trying to change? Are you writing a client side component that is changing the page it is running in?
---
b { font-weight: normal; }
|
|
|
|
|
Ok, fair enough, I am automating navigation through a set of web pages by putting the NET 2.0 Webbrowser control on a dialog. When I get to the third page in the sequence I need to change the default item in a listbox on the web page to the item that I know in advance I want selected. I've been successful in using InvokeMember("Click") to click a button on a web page but I have not been able to "click" on an item in a list in order to select it.
|
|
|
|
|
Hello everyone! My first post here
As you might have guessed from the message title: is it possible to read from a text file, while another application is always writing to it, without disturbing the writing process? And if it is, how do I do it?
I'd like to create an application that open such a file, and gets the data that has been added to the file since my last read (maybe you've got some good suggestions how to do that?).
Thanks in advance,
Paul
|
|
|
|
|
It might be possible to read from the file, but it's hard to guarantee that it would never disturb the writing process.
It sounds like you should use something that has much better functionality to handle multiple users, like a database.
---
b { font-weight: normal; }
|
|
|
|
|
That is true, but my question was more out of curiosity after observing programs like AviPreview or VLAN play avi or mpg files while they were still being downloaded. I hope someone knows a solution because this is driving me nuts
|
|
|
|
|
pistolenpaultje wrote: AviPreview or VLAN play avi or mpg files while they were still being downloaded
I don't know about these programs but it looks like LimeWire just pauses the download while it writes the downloaded bits so far to a temporary file which it then displays. Maybe these programs do the same and you havn't realised.
You know you're a Land Rover owner when the best route from point A to point B is through the mud.
Ed
|
|
|
|
|
Are you talking about something similar to the Unix tail command? If so, you might just want to look at something like this[^].
--
I've killed again, haven't I?
|
|
|
|
|
i looked at that, but it waits until the writing process is complete and then opens the file and reads the changes. i'd like to know how to read a file that is being written to while it happens. Or, probably the same, an application that is writing to the file sporadically but never closes the file handle while it is running.
thank you for your reply though, i'll get there!
maybe this is good material for an article: Advanced File I/O
|
|
|
|
|
I'm not sure how helpful this is, but I accidentally did something like that a while back. I wrote a program that was supposed to start capturing the screen into a WMV. I made the mistake of telling it to start capturing when it lost focus, as well as play the captured file when I manually stopped it. The result was this:
- captured WMV (wrote file)
- played WMV in MediaPlayer
- program lost focus
- program started writing to same WMV just before MP started playing it
- I saw the multiple smaller-and-smaller time-delayed MediaPlayer windows in the video.
Basically, MediaPlayer was reading a file that was being written just a little ahead of it, so I know it's POSSIBLE. It's just a matter of fooling Windows into doing it intentionally.
-Daniel
|
|
|
|