|
Hi, how many columns are returned from the query that populates the datatable? if you're using 'SELECT * FROM...' change it to 'SELECT ChainID, Code, Description FROM...'
Perhaps you could post some of the code if this hasn't helped
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
This is the strangest thing...
That is exacly what my query looks like, its in a stored procedure.
When i populate the datatable the three columns are there and correct...
its only when i create a dataview or use .Select that the extra colum is inserted into my results!!
i'm at home now but i will connect to work later on and give a code example...
cheers for the reply
|
|
|
|
|
I've just had a brainwave...
This datatable is populating a combobox, directly via databinding (datasource, datavalue etc)
To clear the combo box i am setting it's index to -1...
could this or something else related to the combobox be inserting my extra column?
i bet it is. crap that's going to be fun to find.
|
|
|
|
|
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
|
|
|
|