|
When T try to write connectionstring I have error with c#
connectionstring:
code C#
con.ConnectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=HASSAN-2D6107E7\SQLEXPRESS";
error message :Error 1 Unrecognized escape sequence
but when try to use the same connection string using vb.net no error
why dose not c# support "/"?
Ahmed hassan
|
|
|
|
|
hassanasp wrote: why dose not c# support "/"?
It looks like '\' is the problem, not '/'.
Maybe try
con.ConnectionString=@ "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Test;Data Source=HASSAN-2D6107E7\SQLEXPRESS";
*edit* More info: C# String Literals[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
modified on Wednesday, December 3, 2008 12:17 PM
|
|
|
|
|
Hi
Does anybody know how to assign IP address or addresses to a network card. After successfull addition, I should be able to pink to that IP address from another machine.
Another questions:
Can One network card have multiple IP addresses?
Thank you.
|
|
|
|
|
I'm not sure what the .NET equivalent is, but the native IP Helper[^]
APIs can help.
For example: AddIPAddress Function[^] (check the remarks section for more links)
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi
I know that there is a straightforward way to load an assembly in run-time using Assembly.Load and then we can get its types using its GetTypes method.
But that solution has some problems, for example if you try to load an assembly in another directory rather than your project directory (and the assembly has some dependencies to other assemblies) you will get an exception saying it can not load the assembly or one of its dependencies.
I'm working on a design time tool and I want to show a list of types that are included in current solution in a UITypeEditor(Something like a tool that Workflow designer has when you want to pick a ExternalDataExchange).Since this list is being build in design time I just need the name of types(and may be to check if they have some attributes attached to them) and I don't want to load them.
So here I have a question to ask.How can I get a list of type names of classes in current solution in Visual Studio IDE?
Thank you
|
|
|
|
|
I need to update a datatable from a datasource silently. That is, I need to do regularly refresh data in datatable from its source database (MS Access database) without greatly interrupting the user experience. I don't want to clear the table and fill it from an OleDbDataAdapter, but use some other method. Any suggestions would be appreciated.
Thanks.
|
|
|
|
|
If you don't want that the UI goes to nonresponding state, use BackgroundWorker[^] class to fetch the data.
When fetching the data n DoWork method, use OleDbDataAdapter, OleDbDataReader or what ever is suitable.
|
|
|
|
|
Thanks, Mika. I had thought of a BackgroundWorker, but I was also hoping to retrieve updates while preserving any changes the user was making to the current DataTable. The DataTable.Merge(DataTable) method, where the DataTable passed into the method reflects the current state of the database) seemed like a good option to me, but I have not been able to get the Merge method to work.
If you have any suggestions regarding how to use the Merge method, or any relevant articles to point me to, I would appreciate it.
Thanks.
|
|
|
|
|
polishprogrammer wrote: but I have not been able to get the Merge method to work
Could you post what you've done so far and what's the problem. Otherwise it's hard to give any hints.
|
|
|
|
|
Afternoon all !
I have populated a list with various animal objects - 'Cat, Dog, Lion, Tiger....'
I am stepping through the list in order to have them call specific methods.
The Cat & Dog object both have the same method Pet(). None of the other animals in the list have this method.
If i implement 2 seperate statments -
foreach (Cat thisCat in zooAnimals.OfType<Cat>())
{
thisCat.pet();
}
foreach (Dog thisDog in zooAnimals.OfType<Dog>())
{
thisDog.pet();
}
the code will work fine.
I would like to know for my own benefit if there's a way to concatenate these statements into 1
i.e
foreach (Cat thisCat in zooAnimals.OfType<Cat>() || Dog thisDog in zooAnimals.OfType<Dog>())
{
thisCat.pet();
thisDog.pet();
}
Thanks in advance
Neil
|
|
|
|
|
The way to do this is to create an interface called IPettable with a single method Pet() .
You then implement this interface for Cat, Dog and any other animal you might want to Pet.
Your code then becomes:
foreach (IPettable pettableAnimal in zooAnimals.OfType<IPettable>())
{
pettableAnimal.pet();
}
|
|
|
|
|
You could do this by implementing an extra interface and then iterating over this interface. Like this:
interface IHasPetMethod
{
void pet();
}
foreach ( IHasPetMethod hasPetMethod in zooAnimals.OfType<IHasPetMethod> )
{
hasPetMethod.pet();
}
This makes the intention of the programmer somewhat clearer (if there is a pet() method, then call it). But compared with your original approach, it's largely a matter of taste and coding style.
Regards
Thomas
www.thomas-weller.de
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Programmer - an organism that turns coffee into software.
modified on Wednesday, December 3, 2008 11:26 AM
|
|
|
|
|
Not really - because OfType<T> takes a specific type you can't interchange between Dog and Cat unless they share some common type (other than 'Animal' which I'm assuming is your base type).
My preference would be that Cat and Dog both implement an IPet interface:
<br />
internal interface IPet<br />
{<br />
void Pet();<br />
}<br />
so that when you're doing your look you call
<br />
foreach (IPet pet in zooAnimals.Oftype<ipet>())<br />
{<br />
pet.Pet();<br />
}<br />
</ipet>
FWIW, I assume you're using yield return in your OfType<t> - it's more efficient than creating an intermediary IEnumerable object to store the results before returning them?
HTH
It definitely isn't definatley
|
|
|
|
|
|
Maybe it's about time I looked at C# 3.0 - and convinced my clients to go down the same road!!
It definitely isn't definatley
|
|
|
|
|
There are genreally two diffrerent approaches to this, and either might make sense in this case.
1. (As suggested already in the thread) You can create in interface IPettable and make the Cat and Doc implement the interface. Then you can check if the object implements the interface:
foreach (Animal animal in zooAnimals) {
IPettable pettable = animal as IPettable;
if (pettable != null) pettable.Pet();
}
2. You can make a common base type for domestic animals:
public abstract class DomesticAnimal : Animal {
public virtual void Pet();
}
Now you make the Cat and Doc classes inherit DomesticAnimal instead of Animal, and implement the Pet method. You can also implement the Pet method in the DomesticAnimal class if the implementation is the same for Cat and Dog.
foreach (Animal animal in zooAnimals) {
DomesticAnimal domestic = animal as DomesticAnimal;
if (domestic != null) domestic.Pet();
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Deusche Version: (für die deutschsprachigen unter uns)
Hi,
Ich möchte eine Anwendung schreiben die aus einem Windows Dienst (Server) und einer Desktopanwendung (Client) besteht. Der Dienst erstellt dabei eine Instanz von einr Klasse, die selbstständig, mit meheren Ressourcen, über dem SerielPort und TCP/IP, arbeitet. Die Desktopanwendung soll sich nun irgend wie mit dem Dienst in Verbindung setzten und dieses Instance abrüfen können um bestimmte Events zu behandel, Eigenschaften abzufragen und methoden auszuführen.
Soweit ich weiß gibt es da eine möglichkeit mittels remoting. Aber bei dem was ich bisher gesehen hab, wird das Object, erst durch den Abruf durch eines Clients erstellt. Ich brauche das Object aber bereits beim Start des Dienstes und nicht erst wenn es irgend jemand abruft.
Daher meine Frage: Wie ist es möglich ein Objekt welches ich selbst erstellt hab, einer Desktopanwendung zur Verfügung zu stelllen ?
--------------------------------------------------
english version:
Hi,
I want to write an application with a windows service as server and a desktop application as client. The service creates an instance of class which works independently with serveral resources on the SerielPort and the TCP/IP. The desktop application must be able to connect to the service and get the afore created instance and may handle events, invoke properties and perform methods.
As far as I know there is a possibility using Remoting. But with what I've seen so far, the instance will first created on a demand by a client. But I already need the object on the start of the service and not only when someone demand it.
Thats why my question: How is it possible to expose or provide an instance, which I've created on my own, for a desktop application ?
|
|
|
|
|
It sounds like the resource classes and the remoting classes should be independent of one another. When the service starts it can create and manage whatever resources it's designed to manage and then use remoting simply as a message channel that clients can use to connect and issue commands to the service.
|
|
|
|
|
Hello,
I need to produce Hammersley sequence for n-dim in C#. Does anyone have any expertise?
Thanks
|
|
|
|
|
|
Hi all,
I want to calculate the homography assuming i have 4 points in the original image and 4 points in the resulted image.
x' = xH where x' is the points in the resulted image, H is the homography and x is points in the original image. Please help! Thanks!
|
|
|
|
|
What are points (in this context), what's the function, what have you tried so far?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I am trying to distort the image to my preference. In this case, the points are simply (x1,y1) to (x4,y4). These points will be mapped to my preferred points. Hence calculating the Homograph. The problem here is I couldn't get the 3x3 Homograph.
|
|
|
|
|
|
Take a look at this, particularly slide 14. The effect I hope to get is the same as the ppt provided.
www.csd.uwo.ca/courses/CS837b/lectures/cs837_lec03_mosaic.ppt
Thanks.
|
|
|
|