|
Do you have to use ADO.NET with C# or can you use the older versions of ADO from MDAC?
If you can use ADO are there any "gotchas" (problems) that I should look out for?
Thanks!
-Al
|
|
|
|
|
You can use a OleDbDataAdapter (generic provider) that can communicate with any OLE DB data source.
Connection and Command objects are almost equivalent to their ADO
counterparts.
IIRC, DataAdapter and DataSet have no real equivalent in ADO.
The only job you start at the top is when you dig a grave. This signature was created by "Code Project Quoter".
|
|
|
|
|
It should be possible through COM interop, no idea on any 'gotchas' though.
James
"I despise the city and much prefer being where a traffic jam means a line-up at McDonald's"
Me when telling a friend why I wouldn't want to live with him
|
|
|
|
|
albean wrote:
If you can use ADO are there any "gotchas" (problems) that I should look out for?
If you create lots of ADO Recordsets, your program can behave like it's leaking memory. Technically, it isn't, but it will look like a leaky program.
Don't forget to call System.Runtime.InteropServices.Marshal.ReleaseComObject on every COM object that you have created on managed code, until it returns 0.
Kant wrote:
Actually she replied back to me "You shouldn't fix the bug. You should kill it"
|
|
|
|
|
Daniel Turini wrote:
System.Runtime.InteropServices.Marshal.ReleaseComObject
From Chris's weblog, that doing so in normal desktop apps, which involves modest com interop, this could lead to additional problems.
Even though half of what he say's is above my head, I got curious after reading his concolusion part.
I'm a bit confused here, whether failing to do a releasecomobject would cause a performance penalty or a memory leak.
And also I would get more benefits only if its a server based app.
Here is the link[^]
Cheers,
Kannan
|
|
|
|
|
Kannan Kalyanaraman wrote:
From Chris's weblog, that doing so in normal desktop apps, which involves modest com interop, this could lead to additional problems.
Even though half of what he say's is above my head, I got curious after reading his concolusion part.
I'm a bit confused here, whether failing to do a releasecomobject would cause a performance penalty or a memory leak.
And also I would get more benefits only if its a server based app.
Here is the link
I love Chris's weblog. In this case, he's stating the obvious: after you call releasecomobject until it returns 0, you cannot access the component anymore (right, you released it!).
Now, he's right: on server applications (what I do for living) you normally have a disconnected model, so, once a "job" is finished, it's better you clean up everything, except caching data. On desktop applications, you normally code for responsiveness, so dangling references are common. In this case, you need to be careful to only releasecomobject when no one is accessing it.
If your COM objects are small and not in a big number, you don't have to worry, because it will take time, but the GC will clean it up. It's only on the case when you have 10MB of RAM taken by ADO recordsets that it becomes unacceptable, because it will take ages for the GC to clean up them.
Kant wrote:
Actually she replied back to me "You shouldn't fix the bug. You should kill it"
|
|
|
|
|
Add a reference to the old ado by looking on the .Net tab in the references dialog. There is a reference there to the old adodb called adodb. I don't know of any gotcha's for you. I have only used it briefly. It worked fine for me. Very small project though.
|
|
|
|
|
I'm looking for a page on the Internet or in MSDN that describes the event hierarchy for System.Windows.Forms.Form.
I'm trying to figure out why the form1_load event keeps firing.
Thanks,
al
|
|
|
|
|
Is there something similar to app.path in C# for the path of an application's folders and files.
|
|
|
|
|
If you need the current directory, try Environment.CurrentDirectory
If you want generic Application Data directory,
try Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData
Cheers,
Kannan
|
|
|
|
|
If it's an SWF program, you can also try Application.ExecutablePath .
Greets,
Daniel
|
|
|
|
|
you can also try this :
string str;
string s;
str = Application.UserAppDataPath.ToString();
s = str.Substring(0,3);
MessageBox.Show(s);
that would return in this exapmle "C:\" , because i was testing it from a drive called C
switch(twinsOnWay)
{
case ("twins on the way"):
MessageBox.Show("for mr and mrs dynamic","twins on the way");
break;
|
|
|
|
|
Hi, all:
When I click on the menu item "Save", right after I edit the text in my Textbox control, in my WinForm, it does not cause validation of the TextBox control. Is there any way to force validation of the control. BTW, if I click on the x to close the form or any other controls on the form, it does cause validation. Any help is appreciated. Thanks in advance.
Dion
|
|
|
|
|
DO something like the following, it worked for the same problem:
if (panel1.Controls[0].DataBindings.Count > 0)
panel1.Controls[0].DataBindings[0].BindingManagerBase.EndCurrentEdit();
<a TITLE="See my user info" href=http:
|
|
|
|
|
We want to use the auto-documentation for our C# project. Since the output of the documentation is XML, I believe that I need an xsl or something like that (sorry, I'm not proficient in XML) to transform the file to whatever I want (html, ...).
Is there any example of such a thing, so I could start from there? It would be nice to add one that produces MSDN-like HTML.
|
|
|
|
|
Michel Prévost wrote:
Is there any example of such a thing, so I could start from there? It would be nice to add one that produces MSDN-like HTML.
I hate to ruin the fun you'd have with countless hours of XSL and CSS coding to achieve this result, but someone already did it
http://ndoc.sourceforge.net/[^]
Kant wrote:
Actually she replied back to me "You shouldn't fix the bug. You should kill it"
|
|
|
|
|
Ndoc[^]is the answer
Cheers,
Kannan
|
|
|
|
|
I will surely have a look at it
|
|
|
|
|
Hi,
In MFC I will often create a UI thread and use it as a worker. I do this because I find the message queue that comes with the UI thread to be very handy for recieving messages in order. When it gets a message it does some work. I also use it to aviod race conditions, i.e. I can have many threads sending messages to the queue and MFC/Windows handles the "Reader Writer" issues of the queue.
What is the equivilant of this in C#? Is there a ready made thread with a message queue where all I would have to do is wait (sleep) until a message arrives?
Thanks.
|
|
|
|
|
How to turn off computer on Win98,Me,2000,nt and XP ?
Greetings
S_W
|
|
|
|
|
I don't know if there is a .NET Framework way of doing it, but you could use the ExitWindowsEx[^] API.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
The button on the front?
Works with Linux too!
|
|
|
|
|
Try a class from mentalis.org:
WindowsController[^].
There is an article on code project about shutting down the computer (I needed it yesterday): Timer Computer Shutdown[^]
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
You can also do it with WMI Script
Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery _
("Select * from Win32_OperatingSystem")
For Each ObjOperatingSystem In colOperatingSystems
ObjOperatingSystem.Win32Shutdown(1)
Next
Save this as .vbs file and run it.
you can also reboot with this script.
'Reboot computer script.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate,(ShutDown)}!\\" & _
strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
objOperatingSystem.Reboot()
Next
Bo Hunter
|
|
|
|
|
Does anyone know how to pass an array of strings using unmanaged code? I'm attempting to use unmanaged code to execute an external application with arguments, for example:
c:\matlab\bin\matlab.exe arg1 arg2
The code works fine when arg1 is substitued for a single space character, and matlab executes as if no arguments were passed in. However when arg1 and arg2 are string objects (containing meaningful arguments) in an array of strings, an exception is raised, stating:
"Object reference not set to an instance of an object"
The code which makes the call to the unmanaged code is basically:
public class Win32Wrapper
{
[DllImport("PFA_Win32.dll", EntryPoint="RunExternalApplication", CharSet=CharSet.Ansi)]
private static extern int RunExternalApplication(String application, String[] arguments);
public int RunApplication(String application, String[] arguments)
{
int result = RunExternalApplication(application, arguments);
return result;
}
}
The unmanaged code, written in C++, looks something like:
extern "C" PFA_WIN32_API int __stdcall RunExternalApplication(const char *app, const char *const *argv)
{
return _spawnv(_P_NOWAIT, app, argv);
}
I'd be most appreciative if anyone has done anything similar to this, or can see any flaws in the code.
Thanks
Ash
|
|
|
|