|
The databinding shouldn't be the problem here as that's very much a read-only action... then again, I've had all sorts of problems with the comboBox and datasource properties! Try removing the selection using .SelectedItem = null instead. Can you step through the code and find the point where the extra column is added?
Good luck! Rob
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Here's one for anyone to look out for in the future (i feel like an idiot)
the Description Column should really have been the "Name" column
therefore when i loaded the results into the dataset the name column was blank and the description colum was created
thanks for your help!
A very tired but enlightened Blakey404
|
|
|
|
|
Hi,
I have a Word table, I' ve read the values from this table to data grid. In the last column there is a long text which formatting is changing even within the same cell of table, for example the one part of text is bold, other italic, other underlined, other listed, and particular fragment has NormalStyle, Header 1, Header 2 etc instances of styles.
And my question is: how can I read programatically formatting of text from the single cell (or in general) in that way to be able to recognize the style.
Thank you very much for your help in advance. Each tip will be very helpful
|
|
|
|
|
try
{
// Server SvrNm = new Server();
// SvrNm.ShowDialog();
string line;
StreamReader sr = new StreamReader("Server.ini");
line = sr.ReadLine();
sr.Close();
string connString = "packet size=4096;data source='" + line.Trim() + "';user id='sa';password='';persist security info=False;initial catalog=uhtmch;";
//string connString = "Data Source='"+ line.Trim ()+"';Initial Catalog=uHTMCM;Integrated Security=SSPI;Pooling=False";
//string connString = "server='"+ line.Trim ()+"';database=uHTMCM;uid=sa;pwd=;Integrated Security=true";
conn = new SqlConnection(connString);
conn.Open();
}
Above is the code I wrote to connect to a SQL server database which is on the network(in another pc). The "Server.ini" file has the name of the pc in which the SQL Server ddatabase is running. But every time I run the code It says timeout, The server is not responding. How can I solve this problem?
|
|
|
|
|
try this...
using System.Data.SqlClient;
string ConnString = "User id = sa; Password = yourPassword; Initial Catalog = yourDataBaseName; Data Source = computerName";
SqlConnection sqlConn = new SqlConnection(ConnString);
sqlConn.Open();
SqlCommand cmd = sqlConn.CreateCommand();
cmd.CommandText = "SELECT column FROM table";
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
string someVariable = reader[0].ToString();
}
sqlConn.Close();
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Thank you Harvey.But It's not working. Still same problem.
|
|
|
|
|
im thinking theres a firewall on the PC running the SQL server, i had the same problem before...
you need to either disable the firewall, or enable sql's default port (i think it 1433) so the firewall will let the connection through
hope it helps
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Thank You Harvey.
|
|
|
|
|
Its a pleasure, did it work?
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
Sorry I was out of here for sometime. And thank u that did work. I turned off the firewall of that pc. Now it's working.
Thank u once again
|
|
|
|
|
|
|
Hello everyone,
Here is my OnStop method of Windows service application. When click stop, the error message is, "Error: 1067 The process terminated unexpectedly".
I have tested if remove the Join method, the service can stop gracefully. Does it mean Join method is not allowed to be called in OnStop method of a Windows service? Any ideas?
protected override void OnStop()
{
MyWorkerThread.Join();
this.ExitCode = 0;
}
thanks in advance,
George
|
|
|
|
|
It could be because your worker thread never ends. Did you tried to use the Join method with a timeout parameter?
What are you doing in your worker thread?
|
|
|
|
|
Hi Zoltan,
I have tried with Join(500), still failed. My worker thread is very simple,
it looks like. Any ideas?
The main thread will set stop status, then join the worker thread.
while (true)
{
}
regards,
George
|
|
|
|
|
static volatile bool running = false;
...
running = true;
while (running)
{
}
That should give you the idea
|
|
|
|
|
Thanks leppie!
I think the differences is your code is using volatile and my code is not?
What will be the impact if I do not use volatile in my scenario?
regards,
George
|
|
|
|
|
Not really, or at least I dont think so, I guess it depnds how tight your loops is, either way, if it goes false, it will stop. Does it matter if it does another loop? Probably not.
|
|
|
|
|
I have tried to change to volatile. Not working, strange. Still service stop fail. Any ideas?
regards,
George
|
|
|
|
|
I think the while-sleep method is not the best to check if a thread must stop. You should be using waithandles for that.
Anyway try something simple in your worker thread, and try to isolate the bug.
|
|
|
|
|
Thanks Zoltan,
Do you mean using sleep method will cause service stop error -- as I mentioned in my original question?
regards,
George
|
|
|
|
|
This is the (simplified) body of most thread functions I use in my services...
ServiceController controller = new ServiceController(this.ServiceName);
while (true)
{
if (controller.Status == ServiceControllerStatus.Running)
{
Thread.Sleep(4500);
}
}
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks John,
1.
I have tried your solution can work. My fix code is, leaving OnStop method empty, and the worker thread will sleep 2 seconds, do some work and check whether the controller's status is not Runnning, if not Running, I will stop the worker thread. Is my solution correct?
2.
I think in this solution, the main thread will stopped at first when we choose to stop the service, then the worker thread will stop later, when the main thread exits the OnStop service (when the controller's status is not Runnning)?
3.
If the answer to 2 is yes, my question is, the worker thread in a Windows service is allowed to be stopped after the main thread?
regards,
George
|
|
|
|
|
1) Yeah, it would look something like this:
ServiceController controller = new ServiceController(this.ServiceName);
while (true)
{
if (controller.Status == ServiceControllerStatus.Running)
{
Thread.Sleep(2000);
}
if (controller.Status == ServiceControllerStatus.Running)
{
}
}
If you want decent response times, you should probably always check to see if the service is running before sleeping or doing work.
2) You shouldn't have a problem with the order in which threads are stopped unless you spawn a thread that relies on the results generated by threads it spawns.
3) If you're concerned about it, you can use set/get this.CanStop . So, at the top of your thread function, do this:
this.CanStop = false;
and at the end (or before your exit from the thread function), do this:
this.CanStop = true;
Keep in mind that if you're running multiple threads, this won't really work well, and you'll have to setup a similar but different mechanism.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks John,
I found when using administrator account to run the service, everything is fine. So I think it may be the issue of using NT AUTHORITY\Network Service account, which is not granted enough privilege.
Now I am going to try to reproduce this issue, my current question is, when assign the log-on account back to NT AUTHORITY\Network Service, and clicks ok in SCM, there is an error message which indicates me to input a correct password for NT AUTHORITY\Network Service.
But I do not know the password for this account. And I want to reset the password for NT AUTHORITY\Network Service.
How to reset the password for this account? Normally to any other account in the Windows server 2003? I have this question is because I noticed a couple of the Windows Services on my local computer is using this account to log on, I do not want to impact other services when changing the password for account NT AUTHORITY\Network Service.
Any comments?
regards,
George
|
|
|
|