|
I set up a program with the code you posted and it works fine. So I don't know what else to tell you
|
|
|
|
|
I dont know if this works but I doubt it cause its wierd the way your putting it to a question:
ListViewItem myItems = (ListViewItem) listView1.SelectedItems[0];
textBox1.Text = myItems.Text;
textBox2.Text = myItems.SubItems[0].Text;
textBox3.Text = myItems.SubItems[1].Text;
But thats just my guess :shrug:
|
|
|
|
|
I posted something just earlier regarding a similar issue. This isnt something I would normally have trouble with, as this is pretty basic data handling. However, I have another problem
I am executing the following query:
SELECT * FROM Groups WHERE Group = 1
on this table(Group being the primary key):
Groups:
Group | In_Stock | On_Order_Short | On_Order_Long | Lead_Time
1 13 0 0 30
2 3 0 0 30
3 6 0 0 21
4 7 0 0 21
5 10 0 0 21
6 1 30 70 30
It says there is a syntax error in my WHERE clause... It doesn't look like there is an error to me. Can anyone think of something that would be causing this It seems to only be doing it when I use "Group" in the WHERE clause, any other column it will work fine.
Thanks again for any responses
-- modified at 22:10 Wednesday 26th April, 2006
|
|
|
|
|
Group is a sql keyword. Put braces around it it.
SELECT * FROM Groups WHERE [Group] = 1
|
|
|
|
|
I probably should have known that Thanks a million!
|
|
|
|
|
How Can I drag and drop an image inserted to a win richTextBox control ?
|
|
|
|
|
Hi, I am writing a program in C# that runs several stored procedures and then (through another stored procedure) creates and XML file in SQL. I am needing help getting the C# program to read the file and write it to a fixed length text file. Any help would be greatly appreciated.
|
|
|
|
|
Use the XML parsers which the .NET frame work provides and use streamwriter class for writing the file.
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Can someone tell me why this is returning 0?
<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 * FROM Mounts WHERE Group_Number = 1", conn);
conn.Open();
int count = cmd.ExecuteNonQuery();
conn.Close();
Console.WriteLine(count);
}</code>
I am using this to get how many records are in Group 1 of a collection of parts.
The datatable in the database currently looks like this:
Mount_Number Carrier_Part_Number Group_Number
KMC84191 72-62039-02 5
KMK64191 72-62039-00 3
KMK71074 72-62030-aa 1
KMK71374 72-62030-bb 1
KMK72073 72-62030-cc 1
KMK72673 72-62030-dd 1
KMM61901 72-62038-03 6
KMM61990 72-62038-05 2
KMM62600 72-62038-04 6
KMM62690 72-62038-02 2
KMM64191 72-62039-01 4
I'm a little tired so I hope this is a stupid mistake
Thanks for any help!
|
|
|
|
|
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?
|
|
|
|