|
Hi!
Im currently at work so i cant try that code, but looking at the code i cant really see where it changes the value of the connectionstring already made? this is really the only problem i have with my code so if you could point it out a little better for me it would be greatly appreciated as i'm a newbie
Thank you for your answere!
|
|
|
|
|
Once you have your desired connection string you then create the connection. You do not want to have it hang around long since this is a rare resource. So you just use it, get what you need, and close the connection. You keep the connection global to your application. If a database is changed it is just a matter of creating a new Connection object.
|
|
|
|
|
Once again, thank you for your answere... I realize the problem of having the connection string hang around, but i think you may have misundestood me. The connection to the database is not made by the IP address of the SQL server, but rather the name of the server, for instance VM2\MSSQL... I do not want to have to recompile the program for every distribution since the name of the sql server may change, thats why i want to be able to change precisly that string that is created by c# so that it is changable within the program before making the connection, instead of having to recompile and distribute the program for each name the server may have.
Please correct me if i did not understand your post properly, thankfull for your help!
|
|
|
|
|
In my first post I indicate how you have a program config setting which points to the location of the collection of connection strings.
config ---> directory of XmlSerialized connection string object.
| |
v |
Program <-------------------------
The serialized object are as follows:
<Servers>
<Connection name="" connString="" />
<Connection name="" connString="" />
</Servers>
In the collection of connection strings (existing outside of the program) part of the string is server="". So you just need to change the server part of each connection string without the need to recompile the program. And if you need to move the directory that holds these definitions, just change the application config file to point to the new location.
-- modified at 12:59 Thursday 20th April, 2006
|
|
|
|
|
I am using visual studio 2003 .
i downloaded the directx 9 SDK and installed it.
according to many tutorials i should see the directx 9 libreries in the list
when i do add refference but i still dont see those namespaces in the list.
can anyone help?
|
|
|
|
|
First you should check to see if you properly installed. Assuming you did the default installation, you should see the DirectX folders at :
C:\WINDOWS\Microsoft.NET\Managed DirectX
There will be a subdirectory for each version of DirectX you have installed.
After that it is a simple matter of running VS, opening your project, doing and Add Reference, and scrolling down to Microsoft.DirectX.
|
|
|
|
|
Please bear with me, this posting is long. I hope somebody has some good ideas here.
My company has a C++ application (call it MyApp) that is allowed to be spawned by a number of 2nd applications. The 2nd application runs MyApp, then registers a special message type and sends the message. I don't have the source code for MyApp (It was before my time). Some ofthe 2nd applications are developed by other companies, but I have the source code for one of them. The 2nd application actually has 2 sections of code where it spawns MyApp. One of them uses:
UINT WM_MYMESSAGE = RegisterWindowMessage("My Special Message");<br />
WinExec("MyApp", SW_SHOW);<br />
SendMessage(HWND_BROADCAST, WM_MYMESSAGE, (WPARAM)m_hWnd, 0L);
the other uses CreateProcess instead of WinExec.
MyApp, when starting up, also registers the message type, then listens for the message and processes it when it is received. MyApp also makes sure that there is only one instance of itself running. If, during startup, it sees another instance out there, it brings the other instance to foreground, restores it if minimized, and then quietly kills itself. Therefore, MyApp receives and processes the message sucessfully if it was already running when the 2nd application sent the message, or if it was not yet running.
Cut to the present. We have recoded MyApp into C#/.NET environment, and we need this behavior to still work the same, without any change to the 2nd applications. MyApp is a Windows.Forms application, and one of the first things it does in Main() is call
static UInt32 WM_MYMESSAGE = RegisterWindowMessage("My Special Message");
next, it creates an instance of the main form:
Form myApp = new MyApp();
then, after performing other startup tasks, it runs it:
Application.Run(myApp);
The main form has an override of WndProc() which does pretty much this:
protected override void WndProc(ref Message m)<br />
{<br />
if(m.Msg == WM_MYMESSAGE )<br />
{<br />
ProcessMyMessage( m.WParam,m.LParam); <br />
}<br />
base.WndProc(ref m);<br />
}
This version of MyApp also prevents multiple instances of itself from running in the same way the C++ version did.
The problem I have is that the C# version correctly receives and processes the special message only when it is already running. When it is not running, it starts up, but the main form never receives the message. I am not sure at this point whether the delay in starting the app means that the message is already gone before MyApp is ready to receive it, or if there is something else going on. It is a fairly large application and takes about 5 to 7 seconds to start up on an average machine. Most of the applications that spawn MyApp are sending the message either immediately after spawning, or waiting at most 5 seconds before sending it. The C++ version works beautifully on fast or slow machines, but the C# version only works when it is already running (even on fast machines).
I have wrestled with this problem for awhile without success. If anybody can shed some light on this I would be most grateful.
Thanks for any help.
Steve
|
|
|
|
|
Hi,
I'm trying to cast a string to a custom type as follows:
msgType = (MessageType) stringArray[2];
but darn .Net keeps telling me it cannot convert type 'string' to 'Server.MessageType'. Any ways around this?
Prob a very simple problem, but any help much appreciated.
|
|
|
|
|
No. You can't just cast a String object to some complete different class. You can only cast an object to it's actual class or any class or interface that it inherits.
What kind of class is Server.MessageType? Why would you think that you could cast a string to that class?
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I have a problem with the exception "Value does not fall within the expected range" and I haven't quite figured out what is wrong in my code.
I have a store procedure that has a declared char for input. The store procedure is used by a Crystal Report filename.
I want to pass a char from C# application that calls the Crystal report and passes a character to it.
Somehow, I got the exception.
I wonder if the character type in VS .Net 2005 is not compatible with a character type in SQL Server 2000.
Any help? Thanks.
Kyah
|
|
|
|
|
It is not really clear in your post just what your are doing and who is generating the problem. You talk about Crystal reports and that is one source of errors, AND you talk about VS vs. SQL Server.
To try and fire some help in the dark -- you will probably have to talk to your DBA first before talking to us. You may also need to go into more details as to how this character is defined, who it is passed to, and so on. Basically, when a problem occurs you need to investigate all aspects of every possible endpoint that generates a potential error.
For example: a character is normally a character. However if you have a setting somewhere (or a type definition) that defines a character as being UNICODE then you will need to consider the fact that you are passing a UNICODE character into a database that is defined as ASCII instead of UNICODE.
However with Crystal Reports in the middle, the error could be from Crystal -- but you don't say. You also do not indicate if the call into the Crystal thing has worked in prior versions of VS or not. That can make a huge difference in the cause of the problem.
Do the homework and then try asking the question after you have done so.
|
|
|
|
|
Hi,
I have a problem with the exception "Value does not fall within the expected range" and I haven't quite figured out what is wrong in my code.
I have a store procedure that has a declared char for input. The store procedure is used by a Crystal Report filename.
I want to pass a char from C# application that calls the Crystal report and passes a character to it.
Somehow, I got the exception.
I wonder if the character type in VS .Net 2005 is not compatible with a character type in SQL Server 2000.
Any help? Thanks.
Kyah
|
|
|
|
|
It's really impossible to tell without first seeing some code.
You should at least try running the software under the debugger and see where the error is occurring. When you find that, post some of that code here--just the relevant pieces--and we should be able to better diagnose your problem.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: I luv teh choco
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
the code is very simple.
void proc()
{
...
callreport(1, 'o');
...
}
void callreport(int a, char b)
{
reportJob = new ExReport() //The ExReport is a Crystal Report connected to
// SQL Server 2000 reported by a store
//procedure with one input type char
reportJob.SetParameterValue(0,b); //"The error happened at this line
...
}
That's all.
The code looks simple but it gave me a lot of headache. Thanks
|
|
|
|
|
I have Dundas Gauge for .NET Version 1.6 [for Visual Studio 2005 ] can I use it with .NET 2003
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
That's probably something you'd have to ask the Dundas people. My guess is no, unless they say "designed for Visual Studio 2005" but didn't actually use any .NET 2 APIs (where VS2005 uses .NET 2 exclusively).
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: I luv teh choco
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
We make versions of the Dundas Gauge product for .Net 1.0, 1.1 and 2.0
So, as long as you install the version for VS 2003 then everything is fine.
If you only received the 2005 version, just email or call your sales rep at Dundas and ask for the VS2003 version as well (you will recieve it at no extra charge).
Troy Marchand
Dundas Software
-- modified at 19:01 Sunday 23rd April, 2006
|
|
|
|
|
Hi Guys!
Is there any tool out there that can be used to convert a Win32 Assembly(dll) to .NET (dll or code).
I would highly appriciate if some1 has an answer!
....Happy Programming....
o O º(`'·.,(`'·., ☆,.·''),.·'')º O o°
»·'"`»* *☆ t4ure4n ☆* *«·'"`«
°o O º(,.·''(,.·'' ☆`'·.,)`'·.,)º O o°
|
|
|
|
|
No, there isn't, and for good reason. One cannot map every single Win32 call into a .NET call. There are usually equivalents or replacements, but certainly no line-for-line equivalence.
|
|
|
|
|
Why won't this code work?
using System;
using System.Windows.Forms;
namespace Practice
{
class Practice
{
public static void Main()
{
// declare and assign a string variable called human
string human;
human = "Walking & talking life";
// declare and assign an int variable called mind
int mind;
mind = 100;
// Print the value of the variables to the console
Console.WriteLine(mind);
Console.WriteLine(human);
}
}
class Continued
{
public static void notMain()
{
MessageBox.Show(human);
MessageBox.Show(mind);
}
}
}
|
|
|
|
|
You did not mention what did not work, but I can guess it is the line:
MessageBox.Show(mind);
unlike Console.WriteLine , MessageBox.Show does not have an overload that takes an int . Try:
MessageBox.Show(mind.ToString());
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
The human and mind variables are only visible inside the Main method. To do what you want you need something like this:
class Practice
{
public static string human;
public static int mind;
public static void Main()
{
human = "Walking & talking life";
mind = 100;
}
}
class Continued
{
public static void notMain()
{
MessageBox.Show(Practice.human);
MessageBox.Show(Practice.mind);
}
}
|
|
|
|
|
I'm writing a Windows Forms application which gets data through a Web
Service. I'm trying to use the IIS HTTP 1.1 native compression. In order to
do that I've added the following methods to the proxy class generated by
Visual Studio:
protected override WebRequest GetWebRequest(Uri uri)<br />
{<br />
WebRequest request = base.GetWebRequest(uri);<br />
request.Headers.Add("Accept-Encoding", "gzip, deflate");<br />
return request;<br />
}<br />
<br />
protected override WebResponse GetWebResponse(WebRequest request)<br />
{<br />
HttpWebResponseDecompressed response = new HttpWebResponseDecompressed(request);<br />
return response;<br />
}
The HttpWebResponseDecompressed class receives the compressed response and
decompress it. This is what is happening: if I remove the second line from
the GetWebRequest method (which adds the header), all the 9 requisitions that
I make on the program's initialization have answer. But when the header is
added, only the first 4 requisitions receive answer (the answer is correctly
compressed).
I've enabled the ASP.NET trace (which generates the trace.axd page) so that
I could see the requests received by IIS and the last 5 do not appear. If I
put a breakpoint in the GetWebRequest method, the breakpoint is hit but they
do not reach IIS.
Can anyone tell me what is happening or what can I do?
Thanks
|
|
|
|
|
I am planning to have an application where a menu will be populated dynamically.
Say the menu for the application is as below:
File Test Help
Test1
Test2
By selecting Test1 and Test2 menu I am intending to load a form from the DLL which inherits a base class used in the main application. This class has a Show method to show the child form which is the part of the DLL. I have difficulty passing the main form as parent form. Since I am novice in C# I am trying to follow the standard method as shown below. Is there any other way to achieve it?
CLib.Class1 cls = new CLib.Class1();
<br />
cls.Parent = this;
cls.Show();
In my show method I have code like below:
frmChild frm = new frmChild();<br />
frm.MdiParent=Parent;<br />
frm.Show();
Second thing, lets us say I maintain the Menu Option name and the DLL name in a INI file or XML file. I can populate the menu option dynamically but how I will use the DLL.
Thanks in advance for your kind guidance.
|
|
|
|
|
1. Answering your first question is a bit difficult because you didn't specify where the code resides in. What exactly is this ? I assume you are not in the parent form... What is the error you are getting?
2. Reflection is the way to go:
using System.Reflection;
Assembly assembly = Assembly.LoadFile("C:\\MyDll.dll");
MyBaseClass cls = assembly.CreateInstance("CLib.Class1");
The LoadFile call is only needed once so you could make this on startup once and then just call CreateInstance several times.
|
|
|
|