|
Probably:
System.Diagnostics.Process.Start("NET STOP MSSQLSERVER");
System.Diagnostics.Process.Start("NET START MSSQLSERVER");
|
|
|
|
|
You can't do it that way, with Process.Start(" ~ DOS NET START/STOP ~ ");
You have to do it like this (assuming SQL Server is running on the same computer as your program):
string localComputer = Environment.MachineName.ToString();
// Stop MSSQLSERVER
ServiceController controller = new ServiceController();
controller.MachineName = localComputer;
controller.ServiceName = "MSSQLSERVER";
string status = controller.Status.ToString();
if (status == "Running")
{
// Stop the service
controller.Stop();
Console.WriteLine("MSSQLSERVER has been stopped.");
}
// Start MSSQLSERVER
controller.MachineName = localComputer;
controller.ServiceName = "MSSQLSERVER";
status = controller.Status.ToString();
if (status == "Stopped")
{
// Stop the service
controller.Start();
Console.WriteLine("MSSQLSERVER has been started.");
}
Also, make sure the service name is MSSQLSERVER in the Services console (Start -> Run -> services.msc). On named instances, this is not always the case.
-Tom
|
|
|
|
|
You can also use the ServiceController[^] class.
Using the GridView is like trying to explain to someone else how to move a third person's hands in order to tie your shoelaces for you.
-Chris Maunder
|
|
|
|
|
How to resize the row height in CF.Framework DataGrid control? For columns there is DataGridColumnStyle , but not the same for rows.
thanks.
|
|
|
|
|
Hi,
Currently I am using the _SelectionChanged event for the dataGridView control to get cell values for the selected row in the control.
Now I would like to order the coluomns by clicking on the header.
But I get an error if a column name is clicked on.
The error occurs on the following line inside _SelectionChanged event:
int rowNum = dataGridView1.CurrentCell.RowIndex;
Obviously at this stage there is no row selected because I have clicked on a column.
I basically would like the column order to work but the above scenario is preventing it.
|
|
|
|
|
dataGridView1.CurrentCell returns null if no cell is selected.
|
|
|
|
|
ERROR:
Cannot find the assembly MyProject, Version=1.0.1123.4445, Culture=neutral, PublicKeyToken=null.
CODE :
<br />
bytes bs[];<-- Receives data from Socket<br />
BinaryFormatter formatter = new BinaryFormatter();<br />
MemoryStream memStream2 = new MemoryStream(bs);<br />
obj = (object)formatter.Deserialize(memStream2);
When you send any data(anything object, like a DataTable) recognized by the framework, it doesn't throw this error.
But when I send my own structure, it throws this exception. Please help.
REFERENCE:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=961147&SiteID=1[^]
But the above thread talks about a web application. Mine is a windows application.
Also note, I'm new to .net
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
You need to add reference to the assembly which define the type you are trying to deserialize in the receiving application.
Usually what we do is, we will find out the classes needed by the both communicating applications into a separate class library and reference to this library in both the applications. I think this will help you solve ur issue at hand.
|
|
|
|
|
Thanks I'll try that.
:Gong: 歡迎光臨 吐 西批 :Gong:
|
|
|
|
|
Hi,
I am developing a project with C# in which i have a shared dataset. On many occasions, I need to delete tables from this dataset for which i call DataSet.Tables.Remove(Tablename). But I have found that this does not work perfectly. Since many times when i make the table with the same name in this dataset after deleting one, i think it contains some extra rows. Can anybody tell me the cause of the problem? Moreover should i call AcceptChanges on the removed table after removing it or it is removed automatically?
Regards,
Wasif Ehsan.
|
|
|
|
|
When you call Remove() (and this applies to DataTables and DataRows), underneath the covers its essentially equivalent to calling Delete() and AcceptChanges(). So, you do not need to call AcceptChanges() when calling Remove().
As for your additional rows, I would try to track down in your debugger the source of those rows.
|
|
|
|
|
I am new to visual C# but I have written a program that will gather hardware and software information from a PC then write this info to a database on a server.
The problem is that I can run the program from my PC, but I want to run it from multiple PCs on the network and I don't know how to set up credentials so everyone can get to the database on the server.
Can this be written in the program?
Thanks in advance.
|
|
|
|
|
Have you looked through the many Database related articles here on Code Project or searched on MSDN for examples?
led mike
|
|
|
|
|
Yes, I have and they have helped me quite a bit.
The only missing piece to this puzzle is the credential thing.
Can you help??
Thanks.
|
|
|
|
|
Beaumont1 wrote: Can you help??
Maybe. Most of the Articles on Database developement here should discuss the login/password part of the database connection string. Is that what you are asking about? Be more specific about "credentials".
led mike
|
|
|
|
|
Yes, you are correct. That's what I am looking for.
Thank you.
|
|
|
|
|
hi,
i want to read from a microprocessor that is directly connected with a croseover ethernet cable
but i dont know how.
on the processor site is everyting in order, i am able to ping to my pc and from my pc using Dos command.
how do i set up the comm using c#??
i know it has something to do with Tcpclient but there i need a portnumber wich i don't know, i don't need acces to the internet.
can anybody help plzz
thx
|
|
|
|
|
A strange question, but I couldn't find anything specific and just trying is not the solution.
Suppose I have two interfaces, lets call them IMyInterface1 an IMyInterface2.
They share a couple of methods (they're identical), but I don't want to use a shared interface with just those methods and then inherit my two interfaces from that one.
Now I have two classes (MyClass1 and MyClass2), each one implementing one of the two interfaces. Both of them must inherit from another class (MarshalByRefObject).
The question is: can I extract a class (MyCommonClass) implementing the common methods of the interfaces, inherit from that class and implement the two classes just implementing the remaining methods? This way MyCommonClass should inherit from MarshalByRefObject, then MyClass1 and MyClass2 should inherit from MyCommonClass.
Are the two interfaces correctly implemented in the compiler's opinion?
Brief pseudo-code:
class MyCommonClass : MarshalByRefObject;
class MyClass1 : MyCommonClass, IMyInterface1;
class MyClass2 : MyCommonClass, IMyInterface2;
Thanks for any help.
|
|
|
|
|
Dario Solera wrote: Are the two interfaces correctly implemented
Short answer: Yes
Bear in mind that any reference to MyCommonClass will not be able to act as iMyInterface1 or IMyInterface2 - only references to either of the MyClass1 or MyClass2
|
|
|
|
|
J4amieC wrote: Bear in mind that any reference to MyCommonClass will not be able to act as iMyInterface1 or IMyInterface2
Yes, that's clear.
Thanks for your reply.
|
|
|
|
|
Dear all.
i am making web application using asp.net and C#(Visual studio 2005). i have listbox(with multi select option) on web form. I am able to capture data through loop. now i want to know how i can place this loop data into single statement for insert statement.
Any one knowing Please guide me.
Thanks
regards
imran khan
|
|
|
|
|
Probably by using prepared statements. It's a bit hard to say without a little more information on what you're inserting.
|
|
|
|
|
Yes i am using prepared statement. Based on listbox selection(can be one or two or three .). i have to insert these value or values along with other information. my problem is i am fetching listbox's values through loop. But how i can insert it in a single insert statement. Please Help..
regards
imran khan
|
|
|
|
|
As I said, it's hard to say without seeing what you're actually doing, I don't know what your query looks like so I can't really comment on how you should do it.
At a wild random guess I'd say setup your statement and parameters before your loop then add parameter values inside your loop, execute the statement after the loop.
|
|
|
|
|
Hello all!
We are working with a partner to integrate customer systems with eachother through EDI. The partner has a solution with translates XML messages to EDI messages and vice versa. All is going well with the translation from XML to EDI. In fact, if you consider the XML standard, all is going well with the translation from EDI to XML. The problem lies within the XML support of the Microsoft MBS Nav software.
The standard XML allows that the order of the attributes in an element varies with every message. For example:
<xmlelement attrib1="1" attrib2="2">
is considered the same as
<xmlelement attrib2="2" attrib1="1">
as far as the standard is concerned. MBS Nav however cannot handle these situations.
I know that .NET 2.0 has decent XML support. I also know a thing or two about C# and .NET. What I don't know, if there is an easy way to generate a XML file with a predetermined order of elements and attributes. I heard something about xsd schemas, but I have never worked with these things before.
Any pointers into a direction are highly appreciated! Thanks in advance.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[ ^]
|
|
|
|