|
Thanks, but that's not what I was looking for...
I want to be able to print the key code...
k.ToString() returns the name of the key...
|
|
|
|
|
Ah, I see what you want, cast it to an int then and you get the value
Console.WriteLine((int)k);
Sig cops got me...
|
|
|
|
|
Thanks a bunch!
|
|
|
|
|
I have a problem when trying to close a connection or the odbcdatareader if I stop it from doing Read() before it would normally be done it hangs. I saw something similar when I Googled this a while ago, but can't find it now. Apparently, the while(dr.Read()) doesn't actually stop even though I used a break; to get out of the while() loop. Anybody run into this before?
|
|
|
|
|
show is a small code snippet of the loop. I have a feeling you're missing something that is causing the loop to continue, and not actually hitting the line to break out of the loop.
|
|
|
|
|
No, I don't think that's it because it breaks from the loop with no problem. I put a breakpoint on the line immediately following the loop and it goes directly there with no problem. This function is being done in a thread of its own so that the user can press 'Cancel' and also updates the UI correctly.
Here's a snippet of what I'm doing:
while (statreader.Read() && !m_bCancel)
{
stemp = statreader["aj_vchar"].ToString();
this.progressBar1.Increment(1);
}
this.progressBar1.Value = 0;
statreader.Close();
I've tried calling Close() on the connection first. I've tried calling Dispose() instead, and I've tried not closing it at all to see what happens when it goes out of scope (statreader). No matter what, this reader hangs on close depening on how many records are in the reader.
When I try it on a test database that returns only a few thousand records, Close() only takes a few seconds. When I try it on a database with about 400,000 records being returned, it takes about 10 minutes for Close() to finish executing.
|
|
|
|
|
Can you show me where you're opening the connection? I'm guessing this would shed more light. Are you creating the DataReader object with the option "commandbehavior.closeconnection"?
|
|
|
|
|
The following comes directly before what I posted earlier:
using (OdbcConnection conn = new OdbcConnection(source))
{
conn.Open();
statcmd = new OdbcCommand("select * from tblPeople", conn);
statcmd = new OdbcCommand(sql, conn);
OdbcDataReader statreader = statcmd.ExecuteReader();
No, I'm not using "commandbehavior.closeconnection" option. Never knew it existed.
|
|
|
|
|
Just a shot in the dark, can you use a OleDb instead of ODBC and see if the problem persists?
|
|
|
|
|
I can try that, but I just never thought to since I'm using an ODBC connection (DSN). I'll let you know if there's any change.
|
|
|
|
|
just tried that; same result, except this time I got some weird error about not being able to switch from COM this-or-that for over 60 seconds.
|
|
|
|
|
I tried the commandbehavior.closeconnection option; didn't make a difference
|
|
|
|
|
MSDN2: DataReader.Close Method [^]
Remarks
You should close data readers when the consumer has completed reading data or no longer wishes to read any more data. Closing the reader ensures that output parameters, if any, are populated.
Depending on the provider implementation, the Close method may wait for the data reader to finish returning all of the specified data before closing. Compare to the Terminate[^] method.
Suggestion:
If you cannot find a provider that supports the Terminate method, you could split your SQL into chunks of 10,000 or so:
select TOP 10000 * from tblPeople where PeopleID > @nLastID order by PeopleID
Looping and creating a new reader each time until you're done, or the user cancels.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
EricDV wrote: Depending on the provider implementation, the Close method may wait for the data reader to finish returning all of the specified data before closing.
Right. I knew I remembered seeing that somewhere. However, the OdbcDataReader doesn't support the Terminate() method. I had already thought about the 'Top xxxx' method, but I was trying to avoid that if possible. Plus, on the database I'm doing it on now, there's about 3 million records, and it's already going to take hours to process those without getting all these different dataSets.
Thanks for your help, though
|
|
|
|
|
Hi,
I have a sql with an outer join that will always return 2 rows. How does the gridview know when they should be INSERTs instead of UPDATEs? It seems to always be wanting to update them. I have even changed the CreateRow routine to be an insert row but it will still calling the DataSourceControl.ExecuteUpdate instead of the DataSourceControl.ExecuteInsert. How do I get it to trigger the insert method?
Thanks, Jessica
|
|
|
|
|
no ideas? anyone?
Thanks, Jessica
|
|
|
|
|
The problem with my code at the moment is that it never goes to the second row, it will keep trying to query to the node detials. e.g: endless loop
I firstly pass the method the top node, and get its children.
So ExampleTopNode is passed to GetChildrenAndExpand, which inturn gets its children from the database and inserts it into the dataset (this works fine).
I then want to sort through ExampleTopNode's children which has now been inserted into "NodeInfo" table and get there children.
private void GetChildrenAndExpand(string Node_Name, string Node_Version)<br />
{<br />
GetChildrenFromDatabase(Node_Name, Node_Version); <br />
<br />
foreach (DataRow row in datatable.["NodeInfo"].Rows)<br />
{<br />
string NewNode_Name = row.ItemArray[0].ToString();<br />
string NewNode_Version = row.ItemArray[1].ToString();<br />
<br />
GetChildrenAndExpand(NewNode_Name, NewNode_Version); <br />
}
Regards,
Gareth.
|
|
|
|
|
Maybe not exactly what you need, but it should give you the idea
<br />
DataTable is loaded prior to this call<br />
<br />
public TreeNode GetFolders()<br />
{<br />
DataRow[] rows = DataTable.Select("ParentID IS NULL");<br />
<br />
TreeNode parent = new TreeNode();<br />
parent.Text = rows[0]["Name"].ToString();<br />
parent.Tag = rows[0]["ID"];<br />
<br />
AddChildNode(parent);<br />
<br />
return parent;<br />
}<br />
<br />
private void AddChildNode(TreeNode node)<br />
{<br />
DataRow[] rows = DataTable.Select("ParentID=" + node.Tag);<br />
foreach(DataRow row in rows)<br />
{<br />
TreeNode child = new TreeNode();<br />
child.Text = row["Name"].ToString();<br />
child.Tag = row["ID"].ToString();<br />
node.Nodes.Add(child);<br />
<br />
AddChildNode(child);<br />
}<br />
}<br />
only two letters away from being an asset
|
|
|
|
|
Thats not really what i want, as im not creating a TreeNode structure, and it doesnt really answer my question.
Thanks for trying anyways.
Regards,
Gareth.
|
|
|
|
|
I see. Have you tried using setting a DataRelation and something like this
foreach(DataRelation relation in table.ChildRelations)<br />
{<br />
foreach(DataRow row in table.Rows)<br />
{<br />
childRows = row.GetChildRows(relation);<br />
}<br />
}<br />
only two letters away from being an asset
|
|
|
|
|
I think your getting confused with with the wording in my first post. I am selecting from 1 datatable. I want to query data from a database and insert it into that datatable and at the same time, sort through the datatable for new rows which have been inserted and do the whole process again
E.g:
So, get data for bob, bob returns 3 peices of data, now get data for those 3 new rows but using the same method as in my first post.
Does that clarify it better?, the problem i beleive with my code is that im using a foreach loop to go through data which im inserting into, thus that loop will never see the new rows beeing added.
|
|
|
|
|
hi everybody,
can anybody tell me how to convert a xml file to doc,htm,pdf and doc file to pdf,htm,xml through C# code.
any help would be appreciated.
thanks in advance
|
|
|
|
|
yes
but you should know what you want to give
what i think you need can be worked out as follows
create a report and let the user save it in desired format (crystal report have it built in)
if you want to do more you should use some more dlls provided by microsoft (for doc rtf xls ) and from adobe (for pdf)
and you should read office automation (sampels provided by microsoft will work fine)
hope that will help
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hi!
I want to receive and send data from local computer( in network LAN) with modem(GSM/GPRS) through GPRS. My computer is connected the router that have static IP. Modem can communication with this static IP. But the problem is ... I don't know how to communication my computer with data of router from internet (using C#)? I can process all data incom router? I don't know how ? who can help me, please?
|
|
|
|
|
You have to specify more clearly what you want to do
Yes, in C#, you can make an application that listens for incoming calls/transactions from the internet, or contact another application/server over the internet.
Find out exactly what you want/need to do and take a look at all the excellent tutorials here on CodeProject.
Best regards.
-Larantz-
for those about to code, we salute you
|
|
|
|