|
Hello Nader Elshehabi,
I am extremely sorry for not replying you in time. I could not get a chance to reply in last 2 days. I have gone thru your suggessions and I have checked the connection string. I found that, connection string was showing absolute path to a single database file rather than dynamically getting the folder name. So, I fixed the path and now it is working excellent. I appreciate your co-operation.
But I was shocked when I found a problem
I have made a installer of My Windows Application (C# 2005 Express) and ported my software to a different computer. my installer installes SQL Server 2005 Express in the target machine at first then copy my software. When I installed the software in that computer and I clicked to run, I got the following error message and Program shut down.
.........................................................................
An error has occured while establishing a connection to the server.
When connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote
connections. (Provider: SQL Netowrk Interfaces, error:26 - Error locating
Server/Instance specified.)
..........................................................................
Would you please guide me about this problem. Why it is looking for remote connection, It is not something like ASP.NET connecting thru Website or something like that. it is the very mdf file which is already available in the same PC and it should be accesssible thru the connection string I programmed in the application, right ?
Thanks and regards
Emran
|
|
|
|
|
I'm sorry I've replied Late, but I hope not too late.
This message appears when there is no connection between your application and SQL server. Not necessarily across a network. You must have realized that you need SQLExpress installed on the user's computer for your application to work. So your deployment project must include an install option to install SQLExpress Before installing your application. To do this, follow these steps:
1- Right click on the name of your deployment project in the Solution explorer
2- Click on the properties
3- Click on the "Prerequisites" Button.
4- Check the check box on top if this dialog, it should say "Create setup program to intstall..."
5- Now, in the list check on
a) Microsoft Data access components
b) .Net framework
c) Windows Installer
d) SQL server 2006 Express Edition
6- You should see three radio buttons in the lower part of the dialog. Check the meddle one.
Now pree OK and SQL express will be installed with your application Only if it's not already installed on the target computer. Notice that It will NOT be uninstalled after uninstalling your application. To do this you have to put it in the custom actions of your setup program.
This will work only if you have Visual Studio 2005. Steps on older versions are more complicated. If this doesn't work for any reason, I'm here for your next post.
|
|
|
|
|
Hi Nader,
Thanks a lot. As I am using Express Editon of C# .Net 2005, I dont have any Setup making feature in my IDE. But I fix my 3rd party installer so that SQL Server is installed. After installing SQL Server, every thing is running ok Now.
One problem I was trying to figure out for a long time.
It is, So many times, When My application try to loads, it takes time and before it loads, Exception is thrown "Timeout Expired". I guessed, this timeout is SQL Server's connection timeout. So, In my config file, I changed the connection time out from 15 seconds to 120 seconds (high enough to get rid of this error), yet, IT looks like, the timeout value is stored in some other place where the value is so low, most of the time, time out expires. Some of my user may have slow computer and all the time they will face this Timeout expire error. Would you please give me a clue about it.
Thanks for your time. I am keep on asking you question, I felt for your time, Insallah Once this Timeout problem is solve, I hope not to bother you again.
Thanks and regards
Emran.
|
|
|
|
|
Dear Emran, I'm realy happy to help you, please don't be so sensitive, you're NOT bothering me at all.
For the loading problem, I feel it's not the SQL timeout, I really doubt it. Do you make any other connections? like using sockets? any other procuders that uses timeout, like browser component?, try to debug your application to that timeout exception, and trace its source. You should make sure that it's SQL timeout before tapering with the connectionstring. Also you said that the old value is 15 seconds. Does your application throws that exception after 15 seconds of loading, or more? or less?? Such answers may help you identifying the source of the exception.
Anyway, if you want to change the Timeout of your connection, don't do it directly from your application's config file, as it changes by building your app. Do it by changing the connection string as follows:
1- Right click on the project's name in the solution explorer.
2- Click on properties
3- Click on the settings tab (located to the left usually)
4- You should see your connection string to the right. When you click on it, a small button with three dtos on it "..." should appear at the right end of the field, click on that button.
5- On the dialog that shows up click on "Advanced" button
6- A property page should appear. Shearch for the timeout property and change it to the value that suits you.
If that solves your problem, then thank God, but if not, try to post me more of your loading code in your constructor and FRAME_LOAD event handler. Also post the Call stack of your exception, so that we could trace the source of the timeout, as I'm not convinced that the problem is in the SQL timeout.
If you have ANY question at ANY time, don't think twice. Post it, or even send it to me as an email, OK?;) I'm waiting for your reply to see if this works out.
|
|
|
|
|
I got a String returned from Database which has 3 lines, like "Test1\n Test2 \n Test3", but it showed in C# TextBox as "Test1 Test2 Test3". It seems C# TextBox can't preserve the line feed character. How can I make it show in TextBox as 3 lines?
Thanks
TinaQ
-- modified at 18:57 Tuesday 16th May, 2006
|
|
|
|
|
1. Make sure your TextBox 's Multiline property is true .
2. TextBox es don't like "\n". Use String.Replace("\n", "\r\n") on the data to give it the CRLF newlines it likes.
--
I've killed again, haven't I?
|
|
|
|
|
You should replace the \n with Environment.NewLine rather than hard coding \r\n
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks a lot, Everyone! Now it worked.
-- modified at 20:06 Tuesday 16th May, 2006
|
|
|
|
|
If you insert Environment.NewLine and Multiline is true, the text will show as multiline. If not, post your code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Now it worked, sorry it's my mistake before. Thanks a lot!!!
|
|
|
|
|
Does anyone know how to stop a service form being killed by the Task Manager or any other method other than the services own stop function.
If this is at all possible?
Cheers
|
|
|
|
|
I don't think it is, as it wouldn't be a particularly desiarable behaviour (unless you were writing a virus or something).
The best way to stop users from meddling with task manager is through user accounts and permissions - an often neglected, but very important, part of system administration.
|
|
|
|
|
Yes, on the Stop function loop for 45 seconds, the service stoper will time out. Now this is kind of stupid to do.
My eMail control
My Blog
|
|
|
|
|
The problem I have this that we have written a service/application that monitors usage and controls access using a booking system to around 3000 workstations, but some users have found that by killing the service this then stops the service from logging them out when the booked time has elapsed
I supposed then answer is testing the current user who is tiring to exit the service and testing the system exit status.
Looping on the on stop would work if you could tell if the workstation is in a state of shutting down forced or not.
|
|
|
|
|
This is more a training problem than a computer problem.
Solution:
Step 1: Identify the user.
Step 2: Fire the user.
Repeat as necessary.
|
|
|
|
|
|
Is there any way to find the compiler's CLR version to use in an #if clause?
Something like:
#if CLR == 2.0
//do this
#endif
Thanks in advance,
Rei
|
|
|
|
|
Every .Netframework leaves a key in:
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy"
For example if the machine has 2.0 Framework installed then there will be:
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\policy\v2.0" key in the registry
try this code:
if (Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\.NETFramework\\policy\\v2.0") != null)
{
//Do something
}
but that will work fine with the if statement, not with the preprocessor directive #if.
|
|
|
|
|
You can't access any C# constructs from the precompiler directives though... only the precompiler variables and a small handful of comparative expressions.
|
|
|
|
|
Sorry for the mistake. I fixed my message though. I will look for it, if I find something I'll let you know.
But, can you give me a hint why you want it in a preprocessor directive rather than ordinary if statement?
|
|
|
|
|
I'm trying to use System.Drawing.BufferedGraphics, which is only available on .NET 2.0. I could use System.Drawing.Bitmap instead, but it's slightly less performant.
Also, some of the form mouse events are slightly different between the two versions.
I want to avoid having two copies of the code if I can, so I want to use the preprocessor to distinguish between the two.
There's one variable, VC_V7 that's used in an example in the C# documentation on MSDN, but that's only for Visual Studio (I think... I'm not sure why it'd be VC_V7).
Thanks for helping
|
|
|
|
|
http://msdn2.microsoft.com/en-us/library/0feaad6z.aspx[^]
The C# compiler itself defines no symbols or macros that you can use in your source code; all symbol definitions must be user-defined.
That's why there's no documentation
Guess I'll have to find some ways to work around it.
Thanks though.
|
|
|
|
|
Hi. I have a winform (with fade-in and fade-out effect) and I run it on VS 2003 and works great. But when I use VS 2005, the winform appears like with flicks, it's like it had a rendering problem. The example works great with VS 2003, but I have to run in in VS 2005.
Any ideas??
Thanks a lot !!!
|
|
|
|
|
Try this in the form's constructor:
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
If that doesn't work, try playing around with the other ControlStyles things.
That might fix it.
|
|
|
|
|
I still have the problem.
Any other ideas ??
Thanks a lot !!!!
|
|
|
|