|
Your code would save a jpeg with a file extension of bmp and not save the file as a bitmap.
|
|
|
|
|
You're right! my bad. it must be :
System.Drawing.Imaging.ImageFormat.Bmp
I'll correct it now.
|
|
|
|
|
Any idea on using DirectShow to convert images?
because as you know, when you watch a video on your computer, it does not take too cpu time because decoding movie frames is one in gpu, not on cpu. Is there any way on using directshow to convert single frame images? I have researched alot on this idea, but all the things I've found is converting movie from one format to another using directshow.
Any suggestions appreciated.
----------
Eric(M.M)
|
|
|
|
|
I'm stepping into a whole new programming world which I'm not used to at the moment and seemingly stuck at the first hurdle.
I have a class called SQLDBConnect.cs This class is given parameters to connect to a database e.g username password, server etc. These are pulled into an SQLConnection and opened. That appears to work fine.
Within another class I am trying to write an INSERT into that database and I'm stuck at the command
SqlCommand myCommand = new SqlCommand();
myCommand.Connection =;
How do I tell the command to use the connection which is opened in the SQLDBConnect class?
As I mentioned I am new to all this and may be taking the wrong approach, I'd appreciate any opinions.
Many Thanks for all help
|
|
|
|
|
You have to open the connection before you can call myCommand.ExecuteXXX . I have a wrapper class that takes care of all that, and I derive new classes from that base class. This base class builds the connection string, opens/closes the connection, and creates the SqlCommand object for each of the various ExecuteXXX methods.
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
That's an interesting thought, thank you. Would others agree?
|
|
|
|
|
Yes.
You may like to lok at one of the plethora of Data Access libraries/frameworks available for various takes on the best way to accomplish this well-defined common task.
|
|
|
|
|
Yes, don't re-invent the wheel. There are many very good examples on CodeProject of Data Access Layers (DAL) or you could look at the Microsoft Enterprise Library as this is well supported and documented.
|
|
|
|
|
I would agree that there is no need to reinvent the wheel. The Microsoft Enterprise Library was constructed to provide a library of ready tuse code to solve common programming problems, like data access.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
Did you ever notice that the spots on the cow appear to spell out "IE8"?
.45 ACP - because shooting twice is just silly ----- "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." - J. Jystad, 2001
|
|
|
|
|
It's actually a bull, and I hadn't looked at it that way. Now I'm sure I won't be able not to.
|
|
|
|
|
You could simply do it by hand, creating a new connection is a pretty simple task.
myCommand.Connection = new SqlConnection("...Connection String...")
If you do a quick web search for connection strings for your specific database, you should be able to set that up in no time.
|
|
|
|
|
I would make the clas SQLDBConnect a static class. I would also give it a method that returns a connection
SqlConnection conn=new SqlConnection();
SqlCommand comm=new SqlCommand();
conn.ConnectionString=SQLDBConnection.getConnectStr();
conn.Open();
comm.Connection=conn;
|
|
|
|
|
Hi,
I would like to code a TCP/UDP server and I've coded a major part of it but it seems like if the server is busy, then I will have a problem.
Here is my Listening code:
private void Listen()
{
Console.WriteLine( "Listening port " + port.ToString() +"." );
listener.Start();
while (KeepWorking)
{
TcpClient client = listener.AcceptTcpClient();
Console.WriteLine("---------------------");
Console.WriteLine(client.Client.RemoteEndPoint.ToString() + " connected.");
ClientHistory.Add( client.Client.RemoteEndPoint.ToString() );
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleCommunication), client);
}
}
If more than one client requests to connect at the same time then one won't be able to connect because I am not listening.
If a client connects and before it's queued to ThreadPool another client wants to connect, it won't be able to connect because I am not listening again.
Is there a way to solve this or is this how every server works?
Thanks.
modified on Tuesday, January 26, 2010 5:24 AM
|
|
|
|
|
From the documentation[^]
"Start will queue incoming connections until you either call the Stop method or it has queued MaxConnections"
That's still open to multiple interpretations.. but I think it means that your problem does not exist because it keeps queuing new connections when you're not blocking on Accept.
Anyway, even if it didn't work that way, the time window in which it can go wrong is infinitesimal, unless ClientHistory.Add does something other than expected (maybe do a blocking write to a logfile or so.. it looks like adding to a List<string> )
|
|
|
|
|
OK, let's assume that I've deleted all those ClientHistory lines. It still seems like two clients can't connect at the exact same time. Between AcceptTcpClient() and QueueUserWorkItem(), server doesn't accept new connections for miliseconds.
|
|
|
|
|
Does it really happen between them, or sometime after the QueueUserWorkItem?
Does the connection handler send/receive any data?
A NIC can only do 1 thing at once so during the send/receive no one can connect (they will be delayed)
|
|
|
|
|
I've never experienced this problem I am talking about. As assumed that, if enough number of clients try to connect this server, they wouldn't be able to.
|
|
|
|
|
Ok, well I was in a good mood and decompiled TcpListener.Start for you.
public void Start()
{
this.Start(0x7fffffff);
}
public void Start(int backlog)
{
if ((backlog > 0x7fffffff) || (backlog < 0))
{
throw new ArgumentOutOfRangeException("backlog");
}
if (Logging.On)
{
Logging.Enter(Logging.Sockets, this, "Start", (string) null);
}
if (this.m_ServerSocket == null)
{
throw new InvalidOperationException(SR.GetString("net_InvalidSocketHandle"));
}
if (this.m_Active)
{
if (Logging.On)
{
Logging.Exit(Logging.Sockets, this, "Start", (string) null);
}
}
else
{
this.m_ServerSocket.Bind(this.m_ServerSocketEP);
this.m_ServerSocket.Listen(backlog); <--- !!see here!!
this.m_Active = true;
if (Logging.On)
{
Logging.Exit(Logging.Sockets, this, "Start", (string) null);
}
}
}
So the result is a call to SomeSocket.Listen(int.MaxValue) , which according to the documentation[^]: "Places a Socket in a listening state. Int32 backlog: The maximum length of the pending connections queue."
In other words, don't worry, the connections are being placed in the backlog. Of course it can happen that connections are being made at a faster rate than you can handle them, which is really just a denial of service attack. You can't do anything about that, no matter how many connections per second you can handle, they could just throw 1 more at you and you'd lose.
So it all comes down to "magic happens in the background in code that you didn't write", in a more theoretical setting in which connections are only accepted while you are waiting for them, you would have a theoretical problem. Fortunately real world sockets don't work that way
|
|
|
|
|
Thank you. I know understand it all.
|
|
|
|
|
Does anyone have a good solution for integrating some C# code into a java application?
without using web services. is ther any way to integration java files using c#
try and try untill reach success..
|
|
|
|
|
You may find some converter tools if you search on the internet.
Me, I'm dishonest. And a dishonest man you can always trust to be dishonest. Honestly. It's the honest ones you want to watch out for...
|
|
|
|
|
|
thanks Abhinav, i found there is a third party tool called GrassHopper, but i dont want to use any third party tool.
try and try untill reach success..
|
|
|
|
|
Rajeshwar Code- Developer wrote: Does anyone have a good solution for integrating some C# code into a java application?
without using web services. is ther any way to integration java files using c#
You seem to have posed your question from both sides. Do you want to use a Java application from within a C# app, or do you want to call a C# library from Java?
MVP 2010 - are they mad?
|
|
|
|