|
hi every one
well I'm having a bit of trouble in setting the bacground color of the windows Form I'm trying to make here. I wanna give it a customized color which is from the picture of a form built previously but it doesnt gove any option to make your own color uknow like the way we make a color if we dont find any availabe color appropriate.
thanks in advance...
|
|
|
|
|
This should work out:
_form.BackColor = Color.FromArgb(1,2,3);
-Larantz-
|
|
|
|
|
thanks alot man I really appreciate this.
|
|
|
|
|
You can also just type in the RGB ints seperated by commas in the background property field. You're not required to use the GUI dialog.
|
|
|
|
|
Hi,
I have a user control B put inside the parent user control A.
On the child control B, I have put a combo box and a BindingSource BS1. In
the load event of child control B, I fetch the
values from the database and put in a generic BindingList of NameValueClass.
(given below)
class NameValueClass
{
private int _id;
public int Id
{
get{return _id;}
set{_id = value;}
}
private string _name;
public int Id
{
get{return _name;}
set{_name = value;}
}
}
BindingList<namevalueclass> list = RetrieveComboValuesFromDataBase();
Next I assign the list to datasource of BindingSource BS1 (given below)
BS1.DataSource = list;
combo.DataSource = BS1;
combo.DataMember = "Name";
combo.ValueMember = "Id" ;
I have put a Grid on Parent control A. Now I want to show some detail data
on grid, On changing the combo box value i.e. As soon as the
value in the combo box is changed, I need to fetch corresponding details
from database and display on grid. What is the best
way to achieve the same using the BindingSource.
Regards,
Rajat.
|
|
|
|
|
Not sure where to ask this question, so I will start here since I am using C#.
I finally got an upgrade to Visual Studio 2005. I converted one of my projects over and cleaned up a few things that VS2005 was complaining about. However, not I can not connect to the SQL server database. If I compile the application with VS2003, the connection works fine. But on VS2005 the connection times out on open.
Is there anything different about the SqlConnection object between VS2003 and VS2005?
The connection string is a standard:
Server=...;User ID=...;Password=...;Database=...
(Of course where the ... is filled in with the appropriate data).
It seems to work when the database is on the local computer. I just can't connect to a remote computer...
-- modified at 13:56 Friday 27th October, 2006
|
|
|
|
|
What things did you clean up exactly? Did you move the connection string to a different place in the app config and change the code retrieving the connection string?
|
|
|
|
|
Nothing changed around the SQL connection code. Really only 2 things change: 1) had some classes that needed to override Dispose(). I guess they added Dispose() to the base class. 2) Had to change from .Handle to using the safe handle stuff.
The odd thing is that the connection string works when the application is run on the machine with the database. It just won't connect over the network. And that is using the exact same connection string with the Server name specified.
Right now the connection string is hardcoded. Later on it will be stored in the registry.
|
|
|
|
|
This just sounds odd. I'm assuming that the 1.1 code works on a remote machine but the 2.0 code does not. Which rules out the possibility that there's a problem with the network setup. But the 2.0 code works on a local SQL server. If it works locally and not remotely, then the first thing to check is that the network and firewall are all set up correctly.
Faced with the problems you have, I would try to reduce everything to the least common denominator. Create a small console app that just runs simple code like this:
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
Console.WriteLine("ServerVersion: {0}", connection.ServerVersion);
Console.WriteLine("State: {0}", connection.State);
}
Then just run it both locally and remotely for 1.1 and 2.0. Then I'd add little pieces from the SQL connection code of your app until I found what broke.
I'm not sure that any of this is helping, but good luck.
|
|
|
|
|
I'm starting to wonder if the Visual Studio 2005 install is bad. This is really weird.
I made the small console app you suggested and ran it on the local machine with the database. Here are the results for the 2003 and 2005 version:
C:\>"test sql 2003"<br />
ServerVersion: 08.00.0194<br />
State: Open<br />
<br />
C:\>"test sql 2005"<br />
ServerVersion: 08.00.0194<br />
State: Open
Then I ran it on a remote machine and got:
C:\>"test sql 2003"<br />
ServerVersion: 08.00.0194<br />
State: Open<br />
<br />
C:\>"test sql 2005"<br />
<br />
Unhandled Exception: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.<br />
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)<br />
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)<br />
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)<br />
at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)<br />
at System.Data.SqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected)<br />
<br />
at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean& marsCapable)<br />
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failoverDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean encrypt, Boolean<br />
trustServerCert, Boolean integratedSecurity, SqlConnection owningObject, Boolean<br />
aliasLookup)<br />
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)<br />
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)<br />
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)<br />
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)<br />
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owning Object)<br />
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)<br />
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)<br />
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)<br />
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)<br />
at System.Data.SqlClient.SqlConnection.Open()<br />
at Test_SQL.Program.Main(String[] args)
I have tried increasing the timeout, but it doesn't help and I should not have to wait 60 seconds for a connection to the database on a local network.
Thanks for the help so far, any ideas of where to go from here?
|
|
|
|
|
Well, just for grins, try using integrated security instead of a sql identity. I doubt it will make a difference. The connection string would look like this: Server=(local);Database=Northwind;Integrated Security=SSPI
|
|
|
|
|
After reading some other forums on this, there are other people complaining about the exact same thing and the typical response is to increase the timeout. You could set it to something obscene like 5 minutes and see if it eventually connects. I suspect it's not the network, so maybe you could try an OLE or ODBC connection to see if anything is working at all.
|
|
|
|
|
That actually worked. Thanks.
The odd thing is that it seems to connect in less than 30 seconds, which was the old timeout value. I set the timeout to 600 seconds. After the first connection, it connects immediately. I guess I will need to connect to the database while the program is initializing to hide the long connect time from the user.
|
|
|
|
|
Weird. Well, I'm glad it works. I guess the good part is that you can open a connection in another thread while you're initializing and .Net will keep a connection pool open for you while your program's still open even if you close the SqlConnection.
|
|
|
|
|
Are you using SQL Server 2005? If so, I believe only the local protocols (named pipe, shared mem) are enabled by default (unlike SQL 2000 where TCP is enabled as well). You may have to enable the desired transport protocol (and possibly unblock it in your firewall) to connect remotely.
|
|
|
|
|
Hey ppl,
What's the best way to get an IntPtr representing my object?
The following works, but I don't know if that's the fashionable way to do it:
IntPtr pObject= Marshal.AllocHGlobal(Marshal.SizeOf(myObject));
Marshal.StructureToPtr(myObject, pObject, true); Also, AFAIK, the StructureToPtr() function copies the data to the new allocated memory, which consumes time.
Is there a better way?
Thanks in advance,
Shy.
|
|
|
|
|
Not by spamming the message bord, for sure.
---
b { font-weight: normal; }
|
|
|
|
|
lol... Sorry everyone...
I pushed the "Post Message" button, and got an error...
So I pushed it again, and again...
BTW... Is anybody else experiencing problem with the site except me (not like the one above)?
|
|
|
|
|
shyagam wrote: BTW... Is anybody else experiencing problem with the site except me (not like the one above)?
Yes that happens from time to time. Some days are worse than others.
shyagam wrote: Is there a better way?
Better how?
led mike
|
|
|
|
|
In my humble opinion there should be a way to simply get the address of an object, and store it as an IntPtr object...
|
|
|
|
|
shyagam wrote: there should be a way to simply get the address of an object
Yes it is in C++. Don't use a garbage collected platform if you want "simple" access to memory.
led mike
|
|
|
|
|
You could delete your redundant messages.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
Absolutly right...
It's done!
I'm used to NOT being able to delete messages in other forums...
|
|
|
|
|
The people here are smart enough to answer a question if it's posted once. Personally, I never answer questions that have been posted several times. It's just a matter of principal.
|
|
|
|
|
Hello everyone!
I want to thank you all up front for any assistance you can provide--I am new, and it will become more obvious here in a second. =)
I am brand new to c# (and visual programming in general, I usually work on Linux) but for a project that I am working on I have the need to get video from a web cam and do image capture.
I have the video working (through directshow) and I am able to take pictures from my video box. Now for the real problem. Over the live video I need to either layer a transparent panel (with border) or draw a rectangle so that the user can decide what portion of the video they wish to capture for the still image. Eventually I will need to let them resize the capture block (keeping ratio) as well.
I hate to speak in generalities, but can anyone get me started please. This is part of an MDI, and thus far I cannot get any panel transparencies to work (they always show the color of the form behind the image, even when the video is the form background)
After a week of brick walls I am coming to the experts for direction--at least point me down the best path if you would..
Thanks for your time and assistance!!
Edwa5823
|
|
|
|